Skip to content

Commit

Permalink
Changing the config read from constants to config.js
Browse files Browse the repository at this point in the history
  • Loading branch information
juturu committed Apr 6, 2017
1 parent 7d84c72 commit ec615dc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export type ConfigOptions = {
production?: boolean,
binLinks?: boolean,
networkConcurrency?: number,
childConcurrency?: number,
networkTimeout?: number,
nonInteractive?: boolean,

Expand Down Expand Up @@ -108,6 +109,8 @@ export default class Config {

networkConcurrency: number;

childConcurrency: number;

//
networkTimeout: number;

Expand Down Expand Up @@ -230,6 +233,13 @@ export default class Config {
constants.NETWORK_CONCURRENCY
);

this.childConcurrency = (
opts.childConcurrency ||
Number(this.getOption('child-concurrency')) ||
Number(process.env.CHILD_CONCURRENCY) ||
constants.CHILD_CONCURRENCY
);

this.networkTimeout = (
opts.networkTimeout ||
Number(this.getOption('network-timeout')) ||
Expand Down
2 changes: 1 addition & 1 deletion src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const NETWORK_CONCURRENCY = 8;
export const NETWORK_TIMEOUT = 30 * 1000; // in milliseconds

// max amount of child processes to execute concurrently
export const CHILD_CONCURRENCY = Number(process.env.CHILD_CONCURRENCY) || 5;
export const CHILD_CONCURRENCY = 5;

export const REQUIRED_PACKAGE_KEYS = ['name', 'version', '_uid'];

Expand Down
2 changes: 1 addition & 1 deletion src/package-install-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ export default class PackageInstallScripts {
const waitQueue = new Set();
const workers = [];

const set = this.reporter.activitySet(installablePkgs, Math.min(constants.CHILD_CONCURRENCY, workQueue.size));
const set = this.reporter.activitySet(installablePkgs, Math.min(this.config.childConcurrency, workQueue.size));

for (const spinner of set.spinners) {
workers.push(this.worker(spinner, workQueue, installed, waitQueue));
Expand Down

0 comments on commit ec615dc

Please sign in to comment.