Skip to content

Commit

Permalink
changed requests batch size to 8 by default instead of number of cpus
Browse files Browse the repository at this point in the history
added cli option to override this batch size
	modified:   bin/ncu
	modified:   lib/versionmanager.js
  • Loading branch information
abnud1 committed Mar 26, 2020
1 parent 21931c3 commit 72b3a6c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions bin/ncu
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ program
.option('-t, --greatest', 'find the highest versions available instead of the latest stable versions')
.option('--timeout <ms>', 'a global timeout in ms')
.option('-u, --upgrade', 'overwrite package file')
.option('--requests-batch-size <n>','requests to npm registry are issued in batches whose size is determined by this option',parseInt,8)
.option('-x, --reject <matches>', 'exclude packages matching the given string, comma-or-space-delimited list, or /regex/')
.option('-v, --version', pkg.version, () => {
console.log(pkg.version);
Expand Down
10 changes: 5 additions & 5 deletions lib/versionmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const versionUtil = require('./version-util.js');
const packageManagers = require('./package-managers');
const prompts = require('prompts');
const pMap = require('p-map');
const os = require('os');
// keep order for setPrecision
const DEFAULT_WILDCARD = '^';

Expand Down Expand Up @@ -256,7 +255,8 @@ function upgradePackageDefinitions(currentDependencies, options) {
json: options.json,
loglevel: options.loglevel,
enginesNode: options.enginesNode,
timeout: options.timeout
timeout: options.timeout,
batchSize: options.requestsBatchSize
}).then(latestVersions => {

const upgradedDependencies = upgradeDependencies(currentDependencies, latestVersions, {
Expand Down Expand Up @@ -456,8 +456,7 @@ function queryVersions(packageMap, options = {}) {
return cint.keyValue(packageList[i], version);
});
}

return pMap(packageList,getPackageVersionProtected,{concurrency: os.cpus().length})
return pMap(packageList,getPackageVersionProtected,{concurrency: options.batchSize})
.then(zipVersions)
.then(_.partialRight(_.pickBy, _.identity));
}
Expand Down Expand Up @@ -562,5 +561,6 @@ module.exports = {
isUpgradeable,
queryVersions,
upgradeDependencies,
upgradeDependencyDeclaration
upgradeDependencyDeclaration,
getPackageManager
};

0 comments on commit 72b3a6c

Please sign in to comment.