Skip to content

Commit

Permalink
Make options.env less surprising
Browse files Browse the repository at this point in the history
  • Loading branch information
sun-zheng-an committed Dec 14, 2014
1 parent 39f0bc2 commit b1165c6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,8 @@ You won't need to set this option unless you encounter a "stdout maxBuffer excee

type: `Object`

default: [`process.env`](http://nodejs.org/api/process.html#process_process_env) with `PATH` prepended by `./node_modules/.bin`, allowing you to run executables in your Node's dependencies.
By default, all the commands will be executed in an environment with all the variables in [`process.env`](http://nodejs.org/api/process.html#process_process_env) and `PATH` prepended by `./node_modules/.bin` (allowing you to run executables in your Node's dependencies).

You can override any environment variables with this option.

For example, setting it to `{PATH: process.env.PATH}` will reset the `PATH` if the default one brings your some troubles.
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ function shell(commands, options) {
throw new gutil.PluginError(PLUGIN_NAME, 'Missing commands')
}

var pathToBin = path.join(process.cwd(), 'node_modules/.bin')
var PATH = pathToBin + path.delimiter + process.env.PATH

options = _.extend({
ignoreErrors: false,
quiet: false,
cwd: process.cwd(),
env: _.defaults({PATH: PATH}, process.env),
maxBuffer: 16 * 1024 * 1024
}, options)

var pathToBin = path.join(process.cwd(), 'node_modules/.bin')
var PATH = pathToBin + path.delimiter + process.env.PATH
options.env = _.extend({}, process.env, {PATH: PATH}, options.env)

var stream = through.obj(function (file, unused, done) {
var self = this

Expand Down

0 comments on commit b1165c6

Please sign in to comment.