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

Commit

Permalink
v1.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Kent C. Dodds committed Nov 12, 2015
2 parents 659e0d3 + 489b04d commit 7794688
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
5 changes: 3 additions & 2 deletions dist/index.js
Expand Up @@ -10,7 +10,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'd

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

var _crossSpawn = require('cross-spawn');
var _crossSpawnAsync = require('cross-spawn-async');

var _managePathDistGetPathVar = require('manage-path/dist/get-path-var');

Expand All @@ -30,7 +30,7 @@ function crossEnv(args) {
var env = _getCommandArgsAndEnvVars2[2];

if (command) {
return (0, _crossSpawn.spawn)(command, commandArgs, { stdio: 'inherit', env: env });
return (0, _crossSpawnAsync.spawn)(command, commandArgs, { stdio: 'inherit', env: env });
}
}

Expand All @@ -47,6 +47,7 @@ function getCommandArgsAndEnvVars(args) {
command = shifted;
break;
}
envVars.APPDATA = process.env.APPDATA;
}
return [command, commandArgs, envVars];
}
Expand Down
6 changes: 3 additions & 3 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "cross-env",
"version": "1.0.3",
"version": "1.0.4",
"description": "Run commands that set environment variables across platforms",
"main": "src/index.js",
"bin": {
Expand All @@ -15,7 +15,7 @@
"check-coverage": "istanbul check-coverage --statements 100 --branches 100 --functions 100 --lines 100",
"report-coverage": "cat ./coverage/lcov.info | codecov",
"test:watch": "mocha src/*.test.js -w --compilers js:babel/register",
"test": "istanbul cover -x *.test.js _mocha -- -R spec src/index.test.js --compilers js:babel/register",
"test": "istanbul cover -x *.test.js node_modules/mocha/bin/_mocha -- -R spec src/index.test.js --compilers js:babel/register",
"prepublish": "npm run build",
"postpublish": "publish-latest",
"semantic-release": "semantic-release pre && npm publish && semantic-release post"
Expand Down Expand Up @@ -63,7 +63,7 @@
}
},
"dependencies": {
"cross-spawn": "2.0.0",
"cross-spawn-async": "2.0.0",
"manage-path": "2.0.0"
}
}
3 changes: 2 additions & 1 deletion src/index.js
@@ -1,4 +1,4 @@
import {spawn} from 'cross-spawn';
import {spawn} from 'cross-spawn-async';
import getPathVar from 'manage-path/dist/get-path-var';
export default crossEnv;

Expand All @@ -24,6 +24,7 @@ function getCommandArgsAndEnvVars(args) {
command = shifted;
break;
}
envVars.APPDATA = process.env.APPDATA;
}
return [command, commandArgs, envVars];
}
11 changes: 6 additions & 5 deletions src/index.test.js
Expand Up @@ -7,7 +7,7 @@ chai.use(sinonChai);

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

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

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

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

function testEnvSetting(...envSettings) {
const ret = crossEnv([...envSettings, 'echo', 'hello world']);
const env = {[getPathVar()]: process.env[getPathVar()]};
env.APPDATA = process.env.APPDATA;
envSettings.forEach(setting => {
const [prop, val] = setting.split('=');
env[prop] = val;
});

expect(ret, 'returns what spawn returns').to.equal('spawn-returned');
expect(proxied['cross-spawn'].spawn).to.have.been.calledOnce;
expect(proxied['cross-spawn'].spawn).to.have.been.calledWith(
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}
);
}
Expand Down

0 comments on commit 7794688

Please sign in to comment.