Skip to content

Commit

Permalink
Fix cwd option not overwriting per command if specified in programmat…
Browse files Browse the repository at this point in the history
…ic usage (#266)
  • Loading branch information
zoton2 committed Apr 5, 2021
1 parent 343d1ab commit 9fa0544
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/concurrently.js
Expand Up @@ -69,6 +69,7 @@ function mapToCommandInfo(command) {
name: command.name || '',
prefixColor: command.prefixColor || '',
env: command.env || {},
cwd: command.cwd || '',
};
}

Expand Down
22 changes: 22 additions & 0 deletions src/concurrently.spec.js
Expand Up @@ -143,3 +143,25 @@ it('uses cwd from options for each command', () => {
cwd: 'foobar',
}));
});

it('uses overridden cwd option for each command if specified', () => {
create(
[
{ command: 'echo', env: { foo: 'bar' }, cwd: 'baz' },
{ command: 'echo', env: { foo: 'baz' } },
],
{
cwd: 'foobar',
}
);

expect(spawn).toHaveBeenCalledTimes(2);
expect(spawn).toHaveBeenCalledWith('echo', expect.objectContaining({
env: expect.objectContaining({ foo: 'bar' }),
cwd: 'baz',
}));
expect(spawn).toHaveBeenCalledWith('echo', expect.objectContaining({
env: expect.objectContaining({ foo: 'baz' }),
cwd: 'foobar',
}));
});

0 comments on commit 9fa0544

Please sign in to comment.