Skip to content

Commit

Permalink
fix(public/exec): stream arguments get passed to command
Browse files Browse the repository at this point in the history
  • Loading branch information
rafamel committed May 5, 2019
1 parent 1c341ef commit 0e96323
Showing 1 changed file with 30 additions and 24 deletions.
54 changes: 30 additions & 24 deletions src/public/exec/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ function stream(
argv: string[],
options: TStreamOptions = {}
): (args?: string[]) => Promise<void> {
return async (args?: string[]) => {
return async (args: string[] = []) => {
args = options.args || args;

let children = await core.children();
if (!children.length) throw Error(`Project has no children`);

Expand All @@ -63,39 +65,43 @@ function stream(
if (!children.length) throw Error(`No project children selected`);

const commands = children.map((child) => {
return [NODE_PATH, KPO_PATH, '@' + child.name].concat(argv);
return [NODE_PATH, KPO_PATH, '@' + child.name]
.concat(argv)
.concat(args.length ? ['--'].concat(args) : []);
});

await (options.parallel
? parallel(commands.map(join), {
? parallel.fn(commands.map(join), {
...options,
cwd: undefined,
names: children.map((child) => '@' + child.name)
})(args)
: series(
commands.reduce(
(acc: string[], cmd, i) =>
acc.concat([
join([
NODE_PATH,
'-e',
oneLine`console.log(
})
: series
.fn(
commands.reduce(
(acc: string[], cmd, i) =>
acc.concat([
join([
NODE_PATH,
'-e',
oneLine`console.log(
"${i === 0 ? 'Scope:' : '\\nScope:'}
${chalk.bold.yellow('@' + children[i].name)}"
)`
]),
join(cmd)
]),
join(cmd)
]),
[]
),
{ ...options, cwd: undefined }
)(args).catch(async (err) => {
throw new errors.WrappedError(
'Series commands execution failed',
null,
err
);
}));
[]
),
{ ...options, cwd: undefined }
)
.catch(async (err) => {
throw new errors.WrappedError(
'Series commands execution failed',
null,
err
);
}));
};
}

Expand Down

0 comments on commit 0e96323

Please sign in to comment.