-
-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bring spawn-command into concurrently (#479)
- Loading branch information
1 parent
c700980
commit 04b7d4a
Showing
8 changed files
with
77 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { getSpawnOpts, spawn } from './spawn'; | ||
|
||
const baseProcess = { | ||
platform: 'win32' as const, | ||
cwd: () => '', | ||
env: {}, | ||
}; | ||
|
||
describe('spawn()', () => { | ||
it('spawns the given command', async () => { | ||
const fakeSpawn = jest.fn(); | ||
spawn('echo banana', {}, fakeSpawn, baseProcess); | ||
expect(fakeSpawn).toHaveBeenCalled(); | ||
expect(fakeSpawn.mock.calls[0][1].join(' ')).toContain('echo banana'); | ||
}); | ||
|
||
it('returns spawned process', async () => { | ||
const childProcess = {}; | ||
const fakeSpawn = jest.fn().mockReturnValue(childProcess); | ||
const child = spawn('echo banana', {}, fakeSpawn, baseProcess); | ||
expect(child).toBe(childProcess); | ||
}); | ||
}); | ||
|
||
describe('getSpawnOpts()', () => { | ||
it('sets detached mode to false for Windows platform', () => { | ||
expect(getSpawnOpts({ process: baseProcess }).detached).toBe(false); | ||
}); | ||
|
||
it('sets stdio to inherit when raw', () => { | ||
expect(getSpawnOpts({ raw: true }).stdio).toBe('inherit'); | ||
}); | ||
|
||
it('merges FORCE_COLOR into env vars if color supported', () => { | ||
const process = { ...baseProcess, env: { foo: 'bar' } }; | ||
expect(getSpawnOpts({ process, colorSupport: false }).env).toEqual(process.env); | ||
expect(getSpawnOpts({ process, colorSupport: { level: 1 } }).env).toEqual({ | ||
FORCE_COLOR: '1', | ||
foo: 'bar', | ||
}); | ||
}); | ||
|
||
it('sets default cwd to process.cwd()', () => { | ||
const process = { ...baseProcess, cwd: () => 'process-cwd' }; | ||
expect(getSpawnOpts({ process }).cwd).toBe('process-cwd'); | ||
}); | ||
|
||
it('overrides default cwd', () => { | ||
const cwd = 'foobar'; | ||
expect(getSpawnOpts({ cwd }).cwd).toBe(cwd); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters