@naturalcycles/nodejs-lib 13.34.1 → 13.34.2

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.
@@ -141,8 +141,8 @@ export interface SpawnOptions {
141
141
  cwd?: string;
142
142
  env?: AnyObject;
143
143
  /**
144
- * Defaults to false for security reasons.
145
- * Set to true to pass `process.env` to the spawned process.
144
+ * Defaults to true.
145
+ * Set to false to NOT pass `process.env` to the spawned process.
146
146
  */
147
147
  passProcessEnv?: boolean;
148
148
  /**
@@ -50,7 +50,7 @@ class Exec2 {
50
50
  async spawnAsync(cmd, opt = {}) {
51
51
  const started = Date.now();
52
52
  this.logStart(cmd, opt);
53
- const { shell = true, printWhileRunning = true, collectOutputWhileRunning = true, throwOnNonZeroCode = true, cwd, env, forceColor = colors_1.hasColors, } = opt;
53
+ const { shell = true, printWhileRunning = true, collectOutputWhileRunning = true, throwOnNonZeroCode = true, cwd, env, passProcessEnv = true, forceColor = colors_1.hasColors, } = opt;
54
54
  let stdout = '';
55
55
  let stderr = '';
56
56
  if (printWhileRunning)
@@ -60,9 +60,9 @@ class Exec2 {
60
60
  shell,
61
61
  cwd,
62
62
  env: {
63
- ...env,
64
- ...(opt.passProcessEnv ? process.env : {}),
63
+ ...(passProcessEnv ? process.env : {}),
65
64
  ...(forceColor ? { FORCE_COLOR: '1' } : {}),
65
+ ...env,
66
66
  },
67
67
  });
68
68
  p.stdout.on('data', data => {
@@ -117,7 +117,7 @@ class Exec2 {
117
117
  spawn(cmd, opt = {}) {
118
118
  const started = Date.now();
119
119
  this.logStart(cmd, opt);
120
- const { shell = true, cwd, env, forceColor = colors_1.hasColors } = opt;
120
+ const { shell = true, cwd, env, passProcessEnv = true, forceColor = colors_1.hasColors } = opt;
121
121
  console.log(''); // 1-line padding before the output
122
122
  const r = node_child_process_1.default.spawnSync(cmd, opt.args, {
123
123
  encoding: 'utf8',
@@ -125,9 +125,9 @@ class Exec2 {
125
125
  shell,
126
126
  cwd,
127
127
  env: {
128
- ...env,
129
- ...(opt.passProcessEnv ? process.env : {}),
128
+ ...(passProcessEnv ? process.env : {}),
130
129
  ...(forceColor ? { FORCE_COLOR: '1' } : {}),
130
+ ...env,
131
131
  },
132
132
  });
133
133
  console.log(''); // 1-line padding after the output
@@ -157,7 +157,7 @@ class Exec2 {
157
157
  exec(cmd, opt = {}) {
158
158
  const started = Date.now();
159
159
  this.logStart(cmd, opt);
160
- const { cwd, env, timeout } = opt;
160
+ const { cwd, env, passProcessEnv = true, timeout } = opt;
161
161
  try {
162
162
  const s = node_child_process_1.default
163
163
  .execSync(cmd, {
@@ -168,8 +168,8 @@ class Exec2 {
168
168
  cwd,
169
169
  timeout,
170
170
  env: {
171
+ ...(passProcessEnv ? process.env : {}),
171
172
  ...env,
172
- ...(opt.passProcessEnv ? process.env : {}),
173
173
  },
174
174
  })
175
175
  .trim();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/nodejs-lib",
3
- "version": "13.34.1",
3
+ "version": "13.34.2",
4
4
  "scripts": {
5
5
  "prepare": "husky",
6
6
  "build": "dev-lib build",
package/src/util/exec2.ts CHANGED
@@ -60,6 +60,7 @@ class Exec2 {
60
60
  throwOnNonZeroCode = true,
61
61
  cwd,
62
62
  env,
63
+ passProcessEnv = true,
63
64
  forceColor = hasColors,
64
65
  } = opt
65
66
  let stdout = ''
@@ -72,9 +73,9 @@ class Exec2 {
72
73
  shell,
73
74
  cwd,
74
75
  env: {
75
- ...env,
76
- ...(opt.passProcessEnv ? process.env : {}),
76
+ ...(passProcessEnv ? process.env : {}),
77
77
  ...(forceColor ? { FORCE_COLOR: '1' } : {}),
78
+ ...env,
78
79
  },
79
80
  })
80
81
 
@@ -131,7 +132,7 @@ class Exec2 {
131
132
  spawn(cmd: string, opt: SpawnOptions = {}): void {
132
133
  const started = Date.now()
133
134
  this.logStart(cmd, opt)
134
- const { shell = true, cwd, env, forceColor = hasColors } = opt
135
+ const { shell = true, cwd, env, passProcessEnv = true, forceColor = hasColors } = opt
135
136
  console.log('') // 1-line padding before the output
136
137
 
137
138
  const r = cp.spawnSync(cmd, opt.args, {
@@ -140,9 +141,9 @@ class Exec2 {
140
141
  shell,
141
142
  cwd,
142
143
  env: {
143
- ...env,
144
- ...(opt.passProcessEnv ? process.env : {}),
144
+ ...(passProcessEnv ? process.env : {}),
145
145
  ...(forceColor ? { FORCE_COLOR: '1' } : {}),
146
+ ...env,
146
147
  },
147
148
  })
148
149
 
@@ -175,7 +176,7 @@ class Exec2 {
175
176
  exec(cmd: string, opt: ExecOptions = {}): string {
176
177
  const started = Date.now()
177
178
  this.logStart(cmd, opt)
178
- const { cwd, env, timeout } = opt
179
+ const { cwd, env, passProcessEnv = true, timeout } = opt
179
180
 
180
181
  try {
181
182
  const s = cp
@@ -187,8 +188,8 @@ class Exec2 {
187
188
  cwd,
188
189
  timeout,
189
190
  env: {
191
+ ...(passProcessEnv ? process.env : {}),
190
192
  ...env,
191
- ...(opt.passProcessEnv ? process.env : {}),
192
193
  },
193
194
  })
194
195
  .trim()
@@ -326,8 +327,8 @@ export interface SpawnOptions {
326
327
 
327
328
  env?: AnyObject
328
329
  /**
329
- * Defaults to false for security reasons.
330
- * Set to true to pass `process.env` to the spawned process.
330
+ * Defaults to true.
331
+ * Set to false to NOT pass `process.env` to the spawned process.
331
332
  */
332
333
  passProcessEnv?: boolean
333
334
  /**