Skip to content

Commit

Permalink
feat(crossEnv): add crossEnv which uses cross-env
Browse files Browse the repository at this point in the history
Closes #1
Closes #2 (`cross-env` can do what `cross-var` does)
  • Loading branch information
Kent C. Dodds committed Mar 2, 2017
1 parent e341807 commit 3e554d0
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"common-tags": "^1.4.0",
"concurrently": "^3.4.0",
"cpy-cli": "^1.0.1",
"cross-env": "^3.1.4",
"is-windows": "^1.0.0",
"mkdirp": "^0.5.1",
"opn-cli": "^3.1.0",
Expand Down
4 changes: 4 additions & 0 deletions src/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ exports[`copy as darwin 1`] = `"node node_modules/cpy-cli/cli.js \\"**/*.html\\"

exports[`copy as win32 1`] = `"node node_modules/cpy-cli/cli.js \\"**/*.html\\" \\"../dist/\\" --cwd=src --parents"`;

exports[`crossEnv as darwin 1`] = `"node node_modules/cross-env/bin/cross-env.js NODE_ENV=test jest"`;

exports[`crossEnv as win32 1`] = `"node node_modules/cross-env/bin/cross-env.js NODE_ENV=test jest"`;

exports[`ifNotWindows as darwin 1`] = `"echo main"`;

exports[`ifNotWindows as win32 1`] = `"echo alternate"`;
Expand Down
13 changes: 13 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export {
copy,
mkdirp,
open,
crossEnv,
}

/**
Expand Down Expand Up @@ -289,6 +290,18 @@ function open(args) {
return `${getBin('opn-cli', 'opn')} ${args}`
}

/**
* Gets a script that uses the cross-env binary. cross-env
* is a dependency of nps-utils, so you don't need to
* install it yourself.
* @param {string} args - args to pass to cross-env
* learn more from http://npm.im/cross-env
* @return {string} - the command with the cross-env binary
*/
function crossEnv(args) {
return `${getBin('cross-env')} ${args}`
}

// utils

function quoteScript(script, escaped) {
Expand Down
1 change: 1 addition & 0 deletions src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const snapshotTests = {
mkdirp: ({mkdirp}) => mkdirp('/tmp/foo/bar/baz'),
open: ({open}) =>
open('http://kentcdodds.com -- "google chrome" --incognito'),
crossEnv: ({crossEnv}) => crossEnv('NODE_ENV=test jest'),
}

Object.keys(snapshotTests).forEach(testName => {
Expand Down
13 changes: 13 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1471,6 +1471,19 @@ create-hmac@^1.1.0, create-hmac@^1.1.2:
create-hash "^1.1.0"
inherits "^2.0.1"

cross-env@^3.1.4:
version "3.1.4"
resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-3.1.4.tgz#56e8bca96f17908a6eb1bc2012ca126f92842130"
dependencies:
cross-spawn "^3.0.1"

cross-spawn@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-3.0.1.tgz#1256037ecb9f0c5f79e3d6ef135e30770184b982"
dependencies:
lru-cache "^4.0.1"
which "^1.2.9"

cross-spawn@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.0.1.tgz#a3bbb302db2297cbea3c04edf36941f4613aa399"
Expand Down

0 comments on commit 3e554d0

Please # to comment.