concurrently
Advanced tools
Comparing version 2.0.0 to 2.1.0
{ | ||
"name": "concurrently", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Run commands concurrently", | ||
@@ -36,3 +36,3 @@ "main": "src/main.js", | ||
"cross-spawn": "^0.2.9", | ||
"lodash": "3.1.0", | ||
"lodash": "^4.5.1", | ||
"moment": "^2.11.2", | ||
@@ -39,0 +39,0 @@ "rx": "2.3.24" |
@@ -5,3 +5,3 @@ # Concurrently | ||
**Version: 2.0.0** ([*previous stable*](https://github.com/kimmobrunfeldt/concurrently/tree/1.0.0)) | ||
**Version: 2.1.0** ([*previous stable*](https://github.com/kimmobrunfeldt/concurrently/tree/2.0.0)) | ||
@@ -117,3 +117,3 @@ Run multiple commands concurrently. | ||
> ```bash | ||
> concurrent --kill-others "npm run watch-js" "npm run watch-less" | ||
> concurrently --kill-others "npm run watch-js" "npm run watch-less" | ||
> ``` | ||
@@ -120,0 +120,0 @@ > |
@@ -24,5 +24,14 @@ #!/usr/bin/env node | ||
// Prefix logging with pid | ||
// Possible values: 'pid', 'none', 'time', 'command', 'index' | ||
// Possible values: 'pid', 'none', 'time', 'command', 'index', 'name' | ||
prefix: 'index', | ||
// List of custom names to be used in prefix template | ||
names: '', | ||
// What to split the list of custom names on | ||
nameSeparator: ',', | ||
// Comma-separated list of chalk color paths to use on prefixes. | ||
prefixColors: 'gray.dim', | ||
// moment format | ||
@@ -69,6 +78,26 @@ timestampFormat: 'YYYY-MM-DD HH:mm:ss.SSS', | ||
'prefix used in logging for each process.\n' + | ||
'Possible values: index, pid, time, command, none or a template. Default: ' + | ||
config.prefix + '. Example template "{time}-{pid}"\n' | ||
'Possible values: index, pid, time, command, name, none, or a template. Default: ' + | ||
config.prefix + '. Example template: "{time}-{pid}"\n' | ||
) | ||
.option( | ||
'-n, --names <names>', | ||
'List of custom names to be used in prefix template.\n' + | ||
'Example names: "main,browser,server"\n' | ||
) | ||
.option( | ||
'--name-separator <char>', | ||
'The character to split <names> on.\n' + | ||
'Default: "' + config.nameSeparator + '". Example usage: ' + | ||
'concurrently -n "styles,scripts|server" --name-separator "|" <command ...>\n' | ||
) | ||
.option( | ||
'-c, --prefix-colors <colors>', | ||
'Comma-separated list of chalk colors to use on prefixes. If there are more commands than colors, the last color will be repeated.\n' + | ||
'Available modifiers: reset, bold, dim, italic, underline, inverse, hidden, strikethrough\n' + | ||
'Available colors: black, red, green, yellow, blue, magenta, cyan, white, gray\n' + | ||
'Available background colors: bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite\n' + | ||
'See https://www.npmjs.com/package/chalk for more information.\n' + | ||
'Default: "' + config.prefixColors + '". Example: "black.bgWhite,cyan,gray.dim"\n' | ||
) | ||
.option( | ||
'-t, --timestamp-format <format>', | ||
@@ -174,2 +203,5 @@ 'specify the timestamp in moment format. Default: ' + | ||
var childrenInfo = {}; | ||
var lastPrefixColor = _.get(chalk, chalk.gray.dim); | ||
var prefixColors = config.prefixColors.split(','); | ||
var names = config.names.split(config.nameSeparator); | ||
var children = _.map(commands, function(cmd, index) { | ||
@@ -187,10 +219,18 @@ // Remove quotes. | ||
} catch (e) { | ||
logError('', 'Error occured when executing command: ' + cmd); | ||
logError('', e.stack); | ||
logError('', chalk.gray.dim, 'Error occured when executing command: ' + cmd); | ||
logError('', chalk.gray.dim, e.stack); | ||
process.exit(1); | ||
} | ||
if (index < prefixColors.length) { | ||
var prefixColorPath = prefixColors[index]; | ||
lastPrefixColor = _.get(chalk, prefixColorPath); | ||
} | ||
var name = index < names.length ? names[index] : ''; | ||
childrenInfo[child.pid] = { | ||
command: cmd, | ||
index: index | ||
index: index, | ||
name: name, | ||
prefixColor: lastPrefixColor | ||
}; | ||
@@ -229,3 +269,3 @@ return child; | ||
function handleOutput(streams, childrenInfo, source) { | ||
var sourceStreams = _.pluck(streams, source); | ||
var sourceStreams = _.map(streams, source); | ||
var combinedSourceStream = Rx.Observable.merge.apply(this, sourceStreams); | ||
@@ -235,3 +275,4 @@ | ||
var prefix = getPrefix(childrenInfo, event.child); | ||
log(prefix, event.data.toString()); | ||
var prefixColor = childrenInfo[event.child.pid].prefixColor; | ||
log(prefix, prefixColor, event.data.toString()); | ||
}); | ||
@@ -243,3 +284,3 @@ } | ||
var exitCodes = []; | ||
var closeStreams = _.pluck(streams, 'close'); | ||
var closeStreams = _.map(streams, 'close'); | ||
var closeStream = Rx.Observable.merge.apply(this, closeStreams); | ||
@@ -253,4 +294,5 @@ | ||
var prefix = getPrefix(childrenInfo, event.child); | ||
var prefixColor = childrenInfo[event.child.pid].prefixColor; | ||
var command = childrenInfo[event.child.pid].command; | ||
logEvent(prefix, command + ' exited with code ' + exitCode); | ||
logEvent(prefix, prefixColor, command + ' exited with code ' + exitCode); | ||
@@ -271,3 +313,3 @@ aliveChildren = _.filter(aliveChildren, function(child) { | ||
delayedExit.subscribe(function() { | ||
logEvent('--> ', 'Sending SIGTERM to other processes..'); | ||
logEvent('--> ', chalk.gray.dim, 'Sending SIGTERM to other processes..'); | ||
@@ -301,3 +343,3 @@ // Send SIGTERM to alive children | ||
// Output emitted errors from child process | ||
var errorStreams = _.pluck(streams, 'error'); | ||
var errorStreams = _.map(streams, 'error'); | ||
var processErrorStream = Rx.Observable.merge.apply(this, errorStreams); | ||
@@ -307,4 +349,4 @@ | ||
var command = childrenInfo[event.child.pid].command; | ||
logError('', 'Error occured when executing command: ' + command); | ||
logError('', event.data.stack); | ||
logError('', chalk.gray.dim, 'Error occured when executing command: ' + command); | ||
logError('', chalk.gray.dim, event.data.stack); | ||
}); | ||
@@ -323,3 +365,3 @@ } | ||
var prefixes = getPrefixes(childrenInfo, child); | ||
if (_.contains(_.keys(prefixes), config.prefix)) { | ||
if (_.includes(_.keys(prefixes), config.prefix)) { | ||
return '[' + prefixes[config.prefix] + '] '; | ||
@@ -338,4 +380,5 @@ } | ||
prefixes.none = ''; | ||
prefixes.pid = child.pid | ||
prefixes.index = childrenInfo[child.pid].index | ||
prefixes.pid = child.pid; | ||
prefixes.index = childrenInfo[child.pid].index; | ||
prefixes.name = childrenInfo[child.pid].name; | ||
prefixes.time = moment().format(config.timestampFormat); | ||
@@ -362,19 +405,19 @@ | ||
function log(prefix, text) { | ||
logWithPrefix(prefix, text); | ||
function log(prefix, prefixColor, text) { | ||
logWithPrefix(prefix, prefixColor, text); | ||
} | ||
function logEvent(prefix, text) { | ||
function logEvent(prefix, prefixColor, text) { | ||
if (config.raw) return; | ||
logWithPrefix(prefix, text, chalk.gray.dim); | ||
logWithPrefix(prefix, prefixColor, text, chalk.gray.dim); | ||
} | ||
function logError(prefix, text) { | ||
function logError(prefix, prefixColor, text) { | ||
// This is for now same as log, there might be separate colors for stderr | ||
// and stdout | ||
logWithPrefix(prefix, text, chalk.red.bold); | ||
logWithPrefix(prefix, prefixColor, text, chalk.red.bold); | ||
} | ||
function logWithPrefix(prefix, text, color) { | ||
function logWithPrefix(prefix, prefixColor, text, color) { | ||
var lastChar = text[text.length - 1]; | ||
@@ -396,5 +439,7 @@ if (config.raw) { | ||
var lines = text.split('\n'); | ||
// Do not bgColor trailing space | ||
var coloredPrefix = colorText(prefix.replace(/ $/, ''), prefixColor) + ' '; | ||
var paddedLines = _.map(lines, function(line, i) { | ||
var coloredLine = color ? colorText(line, color) : line; | ||
return colorText(prefix, chalk.gray.dim) + coloredLine; | ||
return coloredPrefix + coloredLine; | ||
}); | ||
@@ -401,0 +446,0 @@ |
@@ -18,3 +18,3 @@ // Test basic usage of cli | ||
it('help should be succesful', function(done) { | ||
it('help should be successful', function(done) { | ||
run('node ./src/main.js --help', {pipe: DEBUG_TESTS}) | ||
@@ -21,0 +21,0 @@ .then(function(exitCode) { |
@@ -110,3 +110,3 @@ #!/usr/bin/env node | ||
if (!_.contains(['major', 'minor', 'patch'], config.bumpType)) { | ||
if (!_.includes(['major', 'minor', 'patch'], config.bumpType)) { | ||
console.error('Error:', config.bumpType, 'is not a valid bump type'); | ||
@@ -113,0 +113,0 @@ process.exit(1); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
133639
702
+ Addedlodash@4.17.21(transitive)
- Removedlodash@3.1.0(transitive)
Updatedlodash@^4.5.1