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');
|
2022-03-12 01:56:32 +00:00
|
|
|
const isWindows = require('is-windows');
|
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)
|
2021-12-04 17:06:31 +00:00
|
|
|
.filter(v => v.slice(0, 1).pop().toLowerCase() === 'path')
|
2019-08-13 06:47:57 +00:00
|
|
|
.forEach(v => {
|
|
|
|
const key = v.slice(0, 1).pop();
|
2022-03-12 01:56:32 +00:00
|
|
|
env[key] = env[key]
|
|
|
|
? `${nodeModulesBinDir}${isWindows() ? ';' : ':'}${env[key]}`
|
|
|
|
: nodeModulesBinDir;
|
2019-08-13 06:47:57 +00:00
|
|
|
});
|
2019-01-12 03:33:27 +00:00
|
|
|
return env;
|
|
|
|
};
|