mirror of
https://github.com/bower/bower.git
synced 2026-04-24 03:00:19 -04:00
Close GH-507: Add --quiet and --silent command line options. Fixes #343
This commit is contained in:
committed by
André Cruz
parent
a57d2c0e14
commit
eed8025ae2
21
bin/bower
21
bin/bower
@@ -28,7 +28,11 @@ if (reqVer && !semver.satisfies(nodeVer, reqVer)) {
|
||||
throw new Error('Required: node ' + reqVer);
|
||||
}
|
||||
|
||||
shorthand = { 'v': ['--version'] };
|
||||
shorthand = {
|
||||
'v': ['--version'],
|
||||
'q': ['--quiet'],
|
||||
's': ['--silent']
|
||||
};
|
||||
options = { version: Boolean };
|
||||
options = nopt(options, shorthand, process.argv);
|
||||
|
||||
@@ -41,6 +45,9 @@ command = bower.abbreviations[command];
|
||||
|
||||
if (command) bower.command = command;
|
||||
|
||||
if (options.silent) {
|
||||
options.quiet = true;
|
||||
}
|
||||
|
||||
// Temporarory fix for #22 #320 #187
|
||||
var errStatusHandler = function () {
|
||||
@@ -51,16 +58,20 @@ process.on('exit', errStatusHandler);
|
||||
|
||||
bower.commands[bower.command || 'help'].line(input)
|
||||
.on('data', function (data) {
|
||||
if (data) process.stdout.write(data);
|
||||
if (data && !options.quiet) process.stdout.write(data);
|
||||
})
|
||||
.on('end', function (data) {
|
||||
if (data) process.stdout.write(data);
|
||||
if (data && !options.quiet) process.stdout.write(data);
|
||||
})
|
||||
.on('warn', function (warning) {
|
||||
process.stderr.write(template('warn', { message: warning }, true));
|
||||
if (!options.silent) {
|
||||
process.stderr.write(template('warn', { message: warning }, true));
|
||||
}
|
||||
})
|
||||
.on('error', function (err) {
|
||||
if (options.verbose) throw err;
|
||||
process.stdout.write(template('error', { message: err.message }, true));
|
||||
if (!options.silent) {
|
||||
process.stdout.write(template('error', { message: err.message }, true));
|
||||
}
|
||||
errors.push(err);
|
||||
});
|
||||
|
||||
@@ -22,5 +22,7 @@ Commands:
|
||||
Options:
|
||||
|
||||
{{#yellow}}--no-color{{/yellow}} - Do not print colors (available in all commands)
|
||||
{{#yellow}}--quiet{{/yellow}} - Suppress all output except for warnings and errors (available in all commands)
|
||||
{{#yellow}}--silent{{/yellow}} - Suppress all output (available in all commands)
|
||||
|
||||
See 'bower help <command>' for more information on a specific command.
|
||||
|
||||
Reference in New Issue
Block a user