Skip to content
This repository has been archived by the owner on Jan 6, 2021. It is now read-only.

Commit

Permalink
fix(spawn): use cross-spawn for spawn compatibility
Browse files Browse the repository at this point in the history
(cherry picked from commit 9be84e4)
originally by [@NogsMPLS](https://github.com/NogsMPLS) in #3 as
mentioned in #2

closes #2
  • Loading branch information
NogsMPLS authored and Kent C. Dodds committed Nov 11, 2015
1 parent b03e7e3 commit 3c21e49
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"chai": "3.3.0",
"codecov.io": "0.1.6",
"commitizen": "1.0.5",
"cross-spawn": "2.0.0",
"cz-conventional-changelog": "1.1.2",
"eslint": "1.5.1",
"eslint-config-kentcdodds": "4.0.1",
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {spawn} from 'child_process';
import {spawn} from 'cross-spawn';
import getPathVar from 'add-to-path/dist/get-path-var';
export default crossEnv;

Expand Down
10 changes: 5 additions & 5 deletions src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ chai.use(sinonChai);

const {expect} = chai;
const proxied = {
child_process: { // eslint-disable-line camelcase
'cross-spawn': {
spawn: sinon.spy(() => 'spawn-returned')
}
};
Expand All @@ -17,7 +17,7 @@ const crossEnv = proxyquire('./index', proxied);
describe(`cross-env`, () => {

beforeEach(() => {
proxied.child_process.spawn.reset();
proxied['cross-spawn'].spawn.reset();
});

it(`should set environment variables and run the remaining command`, () => {
Expand All @@ -30,7 +30,7 @@ describe(`cross-env`, () => {

it(`should do nothing given no command`, () => {
crossEnv([]);
expect(proxied.child_process.spawn).to.have.not.been.called;
expect(proxied['cross-spawn'].spawn).to.have.not.been.called;
});

function testEnvSetting(...envSettings) {
Expand All @@ -42,8 +42,8 @@ describe(`cross-env`, () => {
});

expect(ret, 'returns what spawn returns').to.equal('spawn-returned');
expect(proxied.child_process.spawn).to.have.been.calledOnce;
expect(proxied.child_process.spawn).to.have.been.calledWith(
expect(proxied['cross-spawn'].spawn).to.have.been.calledOnce;
expect(proxied['cross-spawn'].spawn).to.have.been.calledWith(
'echo', ['hello world'], {stdio: 'inherit', env}
);
}
Expand Down

0 comments on commit 3c21e49

Please sign in to comment.