@zwa73/utils 1.0.235 → 1.0.239

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,6 +11,8 @@ type ExecOpt = Partial<{
11
11
  nodeModules: string;
12
12
  /**工作路径 */
13
13
  cwd: string;
14
+ /**额外环境变量 */
15
+ env: string;
14
16
  }>;
15
17
  /**常用函数 */
16
18
  declare class _UtilFunc {
@@ -34,6 +36,7 @@ declare class _UtilFunc {
34
36
  * @param opt.errlvl - 错误的日志等级
35
37
  * @param opt.nodeModules - nodeModules文件夹路径
36
38
  * @param opt.cwd - 执行目录
39
+ * @param opt.env - 额外环境变量
37
40
  */
38
41
  static exec(command: string, opt?: ExecOpt): Promise<{
39
42
  stdout: string;
@@ -72,11 +72,12 @@ class _UtilFunc {
72
72
  * @param opt.errlvl - 错误的日志等级
73
73
  * @param opt.nodeModules - nodeModules文件夹路径
74
74
  * @param opt.cwd - 执行目录
75
+ * @param opt.env - 额外环境变量
75
76
  */
76
77
  static async exec(command, opt) {
77
78
  return new Promise(async (resolve, reject) => {
78
79
  // 创建一个新的环境变量对象,并将项目的 node_modules/.bin 目录添加到 PATH 环境变量中
79
- const env = Object.create(process.env);
80
+ const env = Object.assign(Object.create(process.env), opt?.env ?? {});
80
81
  const penv = opt?.nodeModules
81
82
  ? path_1.default.join(UtilFileTools_1.UtilFT.currosizePath(opt.nodeModules), '.bin')
82
83
  : UtilFileTools_1.UtilFT.currosizePath(await exports.UtilFunc.memoize(UtilFileTools_1.UtilFT.findNodeModulesDir)(process.cwd(), '.bin') ?? '');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zwa73/utils",
3
- "version": "1.0.235",
3
+ "version": "1.0.239",
4
4
  "description": "my utils",
5
5
  "main": "dist/index.js",
6
6
  "scripts": {