'use strict';constpath=require('path');constpathKey=require('path-key');module.exports=opts=>{opts=Object.assign({cwd:process.cwd(),path:process.env[pathKey()]},opts);letprev;letpth=path.resolve(opts.cwd);constret=[];while(prev!==pth){ret.push(path.join(pth,'node_modules/.bin'));prev=pth;pth=path.resolve(pth,'..');}// ensure the running `node` binary is usedret.push(path.dirname(process.execPath));returnret.concat(opts.path).join(path.delimiter);};module.exports.env=opts=>{opts=Object.assign({env:process.env},opts);constenv=Object.assign({},opts.env);constpath=pathKey({env});opts.path=env[path];env[path]=module.exports(opts);returnenv;};