Skip to content

Commit

Permalink
Add —non-interactive flag for automated processes (#2770)
Browse files Browse the repository at this point in the history
* Add —non-interactive flag for automated processes

* Remove duplicate value
  • Loading branch information
matt-adam authored and bestander committed Feb 26, 2017
1 parent 3d20a52 commit 0adbc59
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ commander.option(
'disable progress bar',
);
commander.option('--network-concurrency <number>', 'maximum number of concurrent network requests', parseInt);
commander.option('--non-interactive', 'do not show interactive prompts');

// get command name
let commandName: ?string = args.shift() || '';
Expand Down Expand Up @@ -373,6 +374,7 @@ config.init({
httpProxy: commander.proxy,
httpsProxy: commander.httpsProxy,
networkConcurrency: commander.networkConcurrency,
nonInteractive: commander.nonInteractive,
commandName,
}).then(() => {

Expand Down
5 changes: 5 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export type ConfigOptions = {
production?: boolean,
binLinks?: boolean,
networkConcurrency?: number,
nonInteractive?: boolean,

// Loosely compare semver for invalid cases like "0.01.0"
looseSemver?: ?boolean,
Expand Down Expand Up @@ -123,6 +124,8 @@ export default class Config {

production: boolean;

nonInteractive: boolean;

//
cwd: string;

Expand Down Expand Up @@ -270,6 +273,8 @@ export default class Config {
this.ignorePlatform = !!opts.ignorePlatform;
this.ignoreScripts = !!opts.ignoreScripts;

this.nonInteractive = !!opts.nonInteractive;

this.requestManager.setOptions({
offline: !!opts.offline && !opts.preferOffline,
captureHar: !!opts.captureHar,
Expand Down
2 changes: 1 addition & 1 deletion src/resolvers/registries/npm-resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default class NpmResolver extends RegistryResolver {
const satisfied = await config.resolveConstraints(Object.keys(body.versions), range);
if (satisfied) {
return body.versions[satisfied];
} else if (request) {
} else if (request && !config.nonInteractive) {
if (request.resolver && request.resolver.activity) {
request.resolver.activity.end();
}
Expand Down

0 comments on commit 0adbc59

Please sign in to comment.