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

21 lines
583 B
JavaScript
Raw Normal View History

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)
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();
env[key] = env[key] ? `${nodeModulesBinDir}:${env[key]}` : nodeModulesBinDir;
});
2019-01-12 03:33:27 +00:00
return env;
};