2019-01-12 03:33:27 +00:00
|
|
|
'use strict';
|
2018-03-18 11:59:38 +00:00
|
|
|
|
2019-01-12 03:33:27 +00:00
|
|
|
const path = require('path');
|
2018-03-18 11:59:38 +00:00
|
|
|
|
2019-01-12 03:33:27 +00:00
|
|
|
module.exports = function getRunCmdEnv() {
|
|
|
|
const env = {};
|
|
|
|
Object.keys(process.env).forEach(key => {
|
|
|
|
env[key] = process.env[key];
|
|
|
|
});
|
2018-03-18 11:59:38 +00:00
|
|
|
// make sure `antd-tools/node_modules/.bin` in the PATH env
|
2019-01-12 03:33:27 +00:00
|
|
|
const nodeModulesBinDir = path.join(__dirname, '../../node_modules/.bin');
|
2019-08-13 06:47:57 +00:00
|
|
|
|
|
|
|
Object.entries(env)
|
|
|
|
.filter(
|
|
|
|
v =>
|
|
|
|
v
|
|
|
|
.slice(0, 1)
|
|
|
|
.pop()
|
|
|
|
.toLowerCase() === 'path',
|
|
|
|
)
|
|
|
|
.forEach(v => {
|
|
|
|
const key = v.slice(0, 1).pop();
|
|
|
|
env[key] = env[key] ? `${nodeModulesBinDir}:${env[key]}` : nodeModulesBinDir;
|
|
|
|
});
|
2019-01-12 03:33:27 +00:00
|
|
|
return env;
|
|
|
|
};
|