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

Commit

Permalink
fix(env): Merge with original environment instead of defining a new one
Browse files Browse the repository at this point in the history
  • Loading branch information
naholyr committed Nov 27, 2015
1 parent 847e80f commit 187c068
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"eslint-plugin-mocha": "1.0.0",
"ghooks": "1.0.0",
"istanbul": "0.3.21",
"manage-path": "2.0.0",
"mocha": "2.3.3",
"proxyquire": "1.7.2",
"publish-latest": "1.1.2",
Expand All @@ -64,6 +65,6 @@
},
"dependencies": {
"cross-spawn-async": "2.0.0",
"manage-path": "2.0.0"
"lodash.assign": "^3.2.0"
}
}
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {spawn} from 'cross-spawn-async';
import getPathVar from 'manage-path/dist/get-path-var';
import assign from 'lodash.assign';
export default crossEnv;

const envSetterRegex = /(\w+)=(\w+)/;
Expand All @@ -13,7 +13,7 @@ function crossEnv(args) {

function getCommandArgsAndEnvVars(args) {
let command;
const envVars = {[getPathVar()]: process.env[getPathVar()]};
const envVars = assign({}, process.env);
const commandArgs = args.slice();
while (commandArgs.length) {
const shifted = commandArgs.shift();
Expand Down
3 changes: 2 additions & 1 deletion src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import sinonChai from 'sinon-chai';
import sinon from 'sinon';
import proxyquire from 'proxyquire';
import getPathVar from 'manage-path/dist/get-path-var';
import assign from 'lodash.assign';
chai.use(sinonChai);

const {expect} = chai;
Expand Down Expand Up @@ -45,7 +46,7 @@ describe(`cross-env`, () => {
expect(ret, 'returns what spawn returns').to.equal('spawn-returned');
expect(proxied['cross-spawn-async'].spawn).to.have.been.calledOnce;
expect(proxied['cross-spawn-async'].spawn).to.have.been.calledWith(
'echo', ['hello world'], {stdio: 'inherit', env}
'echo', ['hello world'], {stdio: 'inherit', env: assign({}, process.env, env)}
);
}
});

0 comments on commit 187c068

Please sign in to comment.