ant-design-vue/antd-tools/utils/getRunCmdEnv.js

27 lines
637 B
JavaScript
Raw Normal View History

2019-01-12 11:33:27 +08:00
'use strict';
2018-03-18 19:59:38 +08:00
2019-01-12 11:33:27 +08:00
const path = require('path');
2018-03-18 19:59:38 +08:00
2019-01-12 11:33:27 +08:00
module.exports = function getRunCmdEnv() {
const env = {};
Object.keys(process.env).forEach(key => {
env[key] = process.env[key];
});
2018-03-18 19:59:38 +08:00
// make sure `antd-tools/node_modules/.bin` in the PATH env
2019-01-12 11:33:27 +08:00
const nodeModulesBinDir = path.join(__dirname, '../../node_modules/.bin');
2019-08-13 14:47:57 +08: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 11:33:27 +08:00
return env;
};