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 3, 2017
1 parent 16a678d commit 886508a
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,
nonInteractive?: boolean,

// Loosely compare semver for invalid cases like "0.01.0"
Expand Down Expand Up @@ -107,6 +108,8 @@ export default class Config {

networkConcurrency: number;

childConcurrency: number;

//
requestManager: RequestManager;

Expand Down Expand Up @@ -226,6 +229,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.requestManager.setOptions({
userAgent: String(this.getOption('user-agent')),
httpProxy: String(opts.httpProxy || this.getOption('proxy') || ''),
Expand Down
2 changes: 1 addition & 1 deletion src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const LOCKFILE_VERSION = 1;
export const NETWORK_CONCURRENCY = 16;

// 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 886508a

Please sign in to comment.