diff --git a/package.json b/package.json index f876f68..278247a 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/index.js b/src/index.js index 97babb8..dd98f6a 100644 --- a/src/index.js +++ b/src/index.js @@ -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; diff --git a/src/index.test.js b/src/index.test.js index 620b5e1..70ea680 100644 --- a/src/index.test.js +++ b/src/index.test.js @@ -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') } }; @@ -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`, () => { @@ -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) { @@ -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} ); }