Moves the maxWorkers default into the API rather than the CLI

Reviewed By: BYK, davidaurelio

Differential Revision: D6883200

fbshipit-source-id: 9f5a73f873adc3ac39286c7f32d4f759eb36820d
This commit is contained in:
Maël Nison 2018-02-06 03:03:31 -08:00 committed by Facebook Github Bot
parent c2fb238b5d
commit bc6f188a59
3 changed files with 4 additions and 15 deletions

View File

@ -15,8 +15,6 @@
const MetroApi = require('..');
const TerminalReporter = require('../lib/TerminalReporter');
const os = require('os');
const {makeAsyncCommand} = require('../cli-utils');
const {Terminal} = require('metro-core');
@ -35,11 +33,7 @@ exports.builder = (yargs: Yargs) => {
yargs.option('platform', {alias: 'p', type: 'string'});
yargs.option('output-type', {alias: 't', type: 'string'});
yargs.option('max-workers', {
alias: 'j',
type: 'number',
default: Math.max(1, Math.floor(os.cpus().length)),
});
yargs.option('max-workers', {alias: 'j', type: 'number'});
yargs.option('optimize', {alias: 'z', type: 'boolean'});
yargs.option('dev', {alias: 'g', type: 'boolean'});

View File

@ -14,8 +14,6 @@
const MetroApi = require('..');
const os = require('os');
const {watchFile, makeAsyncCommand} = require('../cli-utils');
const {promisify} = require('util');
@ -33,11 +31,7 @@ exports.builder = (yargs: Yargs) => {
yargs.option('host', {alias: 'h', type: 'string', default: 'localhost'});
yargs.option('port', {alias: 'p', type: 'number', default: 8080});
yargs.option('max-workers', {
alias: 'j',
type: 'number',
default: Math.max(1, Math.floor(os.cpus().length)),
});
yargs.option('max-workers', {alias: 'j', type: 'number'});
yargs.option('secure', {type: 'boolean'});
yargs.option('secure-key', {type: 'string'});

View File

@ -22,6 +22,7 @@ const TransformCaching = require('./lib/TransformCaching');
const attachWebsocketServer = require('./lib/attachWebsocketServer');
const defaults = require('./defaults');
const fs = require('fs');
const getMaxWorkers = require('./lib/getMaxWorkers');
const http = require('http');
const https = require('https');
const path = require('path');
@ -78,7 +79,7 @@ async function asyncRealpath(path): Promise<string> {
async function runMetro({
config,
resetCache = false,
maxWorkers = 1,
maxWorkers = getMaxWorkers(),
// $FlowFixMe TODO t0 https://github.com/facebook/flow/issues/183
port = null,
reporter = new TerminalReporter(new Terminal(process.stdout)),