From bc6f188a59a529875681056ad19a7f4bd44708e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Nison?= Date: Tue, 6 Feb 2018 03:03:31 -0800 Subject: [PATCH] Moves the maxWorkers default into the API rather than the CLI Reviewed By: BYK, davidaurelio Differential Revision: D6883200 fbshipit-source-id: 9f5a73f873adc3ac39286c7f32d4f759eb36820d --- packages/metro/src/commands/build.js | 8 +------- packages/metro/src/commands/serve.js | 8 +------- packages/metro/src/index.js | 3 ++- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/packages/metro/src/commands/build.js b/packages/metro/src/commands/build.js index 6de007a6..bd0c6e0f 100644 --- a/packages/metro/src/commands/build.js +++ b/packages/metro/src/commands/build.js @@ -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'}); diff --git a/packages/metro/src/commands/serve.js b/packages/metro/src/commands/serve.js index 7f9e6cb4..92a61569 100644 --- a/packages/metro/src/commands/serve.js +++ b/packages/metro/src/commands/serve.js @@ -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'}); diff --git a/packages/metro/src/index.js b/packages/metro/src/index.js index 89d5e698..d6499b7e 100644 --- a/packages/metro/src/index.js +++ b/packages/metro/src/index.js @@ -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 { 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)),