2 const path = require('path');
3 const pathKey = require('path-key');
5 module.exports = opts => {
8 path: process.env[pathKey()]
12 let pth = path.resolve(opts.cwd);
15 while (prev !== pth) {
16 ret.push(path.join(pth, 'node_modules/.bin'));
18 pth = path.resolve(pth, '..');
21 // ensure the running `node` binary is used
22 ret.push(path.dirname(process.execPath));
24 return ret.concat(opts.path).join(path.delimiter);
27 module.exports.env = opts => {
28 opts = Object.assign({
32 const env = Object.assign({}, opts.env);
33 const path = pathKey({env});
35 opts.path = env[path];
36 env[path] = module.exports(opts);