Skip to content

Commit

Permalink
Merge a66ddb8 into 7263ffe
Browse files Browse the repository at this point in the history
  • Loading branch information
daniloraisi committed Sep 27, 2021
2 parents 7263ffe + a66ddb8 commit 7ffcb26
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 17 deletions.
3 changes: 2 additions & 1 deletion bin/concurrently.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ concurrently(args._.map((command, index) => {
restartDelay: args.restartAfter,
restartTries: args.restartTries,
successCondition: args.success,
timestampFormat: args.timestampFormat
timestampFormat: args.timestampFormat,
prefixColors
}).then(
() => process.exit(0),
() => process.exit(1)
Expand Down
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ module.exports = exports = (commands, options = {}) => {
logger,
conditions: options.killOthers
})
]
],
prefixColors: options.prefixColors || []
});
};

Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 21 additions & 14 deletions src/concurrently.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ module.exports = (commands, options) => {
assert.ok(Array.isArray(commands), '[concurrently] commands should be an array');
assert.notStrictEqual(commands.length, 0, '[concurrently] no commands provided');

const prefixColors = options.prefixColors;

delete options.prefixColors;
options = _.defaults(options, defaults);

const commandParsers = [
Expand All @@ -32,21 +35,25 @@ module.exports = (commands, options) => {
new ExpandNpmWildcard()
];

let lastColor = undefined;
commands = _(commands)
.map(mapToCommandInfo)
.flatMap(command => parseCommand(command, commandParsers))
.map((command, index) => new Command(
Object.assign({
index,
spawnOpts: getSpawnOpts({
raw: options.raw,
env: command.env,
cwd: command.cwd || options.cwd,
}),
killProcess: options.kill,
spawn: options.spawn,
}, command)
))
.map((command, index) => {
lastColor = prefixColors && prefixColors[index] || lastColor;
return new Command(
Object.assign({
index,
spawnOpts: getSpawnOpts({
raw: options.raw,
env: command.env,
cwd: command.cwd || options.cwd,
}),
killProcess: options.kill,
spawn: options.spawn,
}, command, lastColor ? { prefixColor: lastColor } : null)
);
})
.value();

const handleResult = options.controllers.reduce(
Expand All @@ -55,11 +62,11 @@ module.exports = (commands, options) => {
return {
commands,
onFinishCallbacks: _.concat(onFinishCallbacks, onFinish ? [onFinish] : [])
}
};
},
{ commands, onFinishCallbacks: [] }
);
commands = handleResult.commands
commands = handleResult.commands;

const commandsLeft = commands.slice();
const maxProcesses = Math.max(1, Number(options.maxProcesses) || commandsLeft.length);
Expand Down

0 comments on commit 7ffcb26

Please sign in to comment.