Skip to content

Commit

Permalink
Merge 13d88f8 into 105445c
Browse files Browse the repository at this point in the history
  • Loading branch information
daniloraisi committed Sep 28, 2021
2 parents 105445c + 13d88f8 commit b432146
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 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
31 changes: 19 additions & 12 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 Down

0 comments on commit b432146

Please sign in to comment.