Skip to content

Commit

Permalink
Apply the network-concurrency option to the package fetchers (yarnpkg…
Browse files Browse the repository at this point in the history
  • Loading branch information
albertfdp committed Jan 3, 2017
1 parent 0d75a22 commit d1618b2
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ commander.option(
'--no-progress',
'disable progress bar',
);
commander.option('--network-concurrency <number>', 'maximum number of concurrent network requests');
commander.option('--network-concurrency <number>', 'maximum number of concurrent network requests', parseInt);

// get command name
let commandName: ?string = args.shift() || '';
Expand Down
11 changes: 9 additions & 2 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ export default class Config {
//
constraintResolver: ConstraintResolver;

networkConcurrency: number;

//
requestManager: RequestManager;

Expand Down Expand Up @@ -191,6 +193,12 @@ export default class Config {
this.rootModuleFolders.push(path.join(this.cwd, registry.folder));
}

this.networkConcurrency = (
opts.networkConcurrency ||
Number(this.getOption('network-concurrency')) ||
constants.NETWORK_CONCURRENCY
);

this.requestManager.setOptions({
userAgent: String(this.getOption('user-agent')),
httpProxy: String(opts.httpProxy || this.getOption('proxy') || ''),
Expand All @@ -200,8 +208,7 @@ export default class Config {
cafile: String(opts.cafile || this.getOption('cafile') || ''),
cert: String(opts.cert || this.getOption('cert') || ''),
key: String(opts.key || this.getOption('key') || ''),
networkConcurrency: Number(opts.networkConcurrency || this.getOption('network-concurrency') ||
constants.NETWORK_CONCURRENCY),
networkConcurrency: this.networkConcurrency,
});

//init & create cacheFolder, tempFolder
Expand Down
2 changes: 1 addition & 1 deletion src/package-fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,6 @@ export default class PackageFetcher {
if (tick) {
tick(ref.name);
}
});
}, this.config.networkConcurrency);
}
}

0 comments on commit d1618b2

Please sign in to comment.