@naturalcycles/nodejs-lib 13.33.1 → 13.34.0
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.
- package/dist/util/exec2.d.ts +10 -0
- package/dist/util/exec2.js +19 -7
- package/package.json +1 -1
- package/src/util/exec2.ts +31 -7
package/dist/util/exec2.d.ts
CHANGED
|
@@ -140,6 +140,11 @@ export interface SpawnOptions {
|
|
|
140
140
|
name?: string;
|
|
141
141
|
cwd?: string;
|
|
142
142
|
env?: AnyObject;
|
|
143
|
+
/**
|
|
144
|
+
* Defaults to false for security reasons.
|
|
145
|
+
* Set to true to pass `process.env` to the spawned process.
|
|
146
|
+
*/
|
|
147
|
+
passProcessEnv?: boolean;
|
|
143
148
|
}
|
|
144
149
|
export interface ExecOptions {
|
|
145
150
|
/**
|
|
@@ -163,5 +168,10 @@ export interface ExecOptions {
|
|
|
163
168
|
cwd?: string;
|
|
164
169
|
timeout?: NumberOfMilliseconds;
|
|
165
170
|
env?: AnyObject;
|
|
171
|
+
/**
|
|
172
|
+
* Defaults to false for security reasons.
|
|
173
|
+
* Set to true to pass `process.env` to the spawned process.
|
|
174
|
+
*/
|
|
175
|
+
passProcessEnv?: boolean;
|
|
166
176
|
}
|
|
167
177
|
export {};
|
package/dist/util/exec2.js
CHANGED
|
@@ -57,8 +57,10 @@ class Exec2 {
|
|
|
57
57
|
const p = node_child_process_1.default.spawn(cmd, opt.args || [], {
|
|
58
58
|
shell,
|
|
59
59
|
cwd,
|
|
60
|
-
env
|
|
61
|
-
|
|
60
|
+
env: {
|
|
61
|
+
...env,
|
|
62
|
+
...(opt.passProcessEnv ? process.env : {}),
|
|
63
|
+
},
|
|
62
64
|
});
|
|
63
65
|
p.stdout.on('data', data => {
|
|
64
66
|
if (collectOutputWhileRunning) {
|
|
@@ -115,8 +117,10 @@ class Exec2 {
|
|
|
115
117
|
stdio: 'inherit',
|
|
116
118
|
shell,
|
|
117
119
|
cwd,
|
|
118
|
-
env
|
|
119
|
-
|
|
120
|
+
env: {
|
|
121
|
+
...env,
|
|
122
|
+
...(opt.passProcessEnv ? process.env : {}),
|
|
123
|
+
},
|
|
120
124
|
});
|
|
121
125
|
this.logFinish(cmd, opt, started);
|
|
122
126
|
if (r.error) {
|
|
@@ -153,8 +157,10 @@ class Exec2 {
|
|
|
153
157
|
// shell: undefined,
|
|
154
158
|
cwd,
|
|
155
159
|
timeout,
|
|
156
|
-
env
|
|
157
|
-
|
|
160
|
+
env: {
|
|
161
|
+
...env,
|
|
162
|
+
...(opt.passProcessEnv ? process.env : {}),
|
|
163
|
+
},
|
|
158
164
|
})
|
|
159
165
|
.trim();
|
|
160
166
|
}
|
|
@@ -192,7 +198,13 @@ class Exec2 {
|
|
|
192
198
|
logFinish(cmd, opt, started) {
|
|
193
199
|
if (!opt.logFinish && !opt.log)
|
|
194
200
|
return;
|
|
195
|
-
console.log([
|
|
201
|
+
console.log([
|
|
202
|
+
(0, colors_1.white)(opt.name || cmd),
|
|
203
|
+
...((!opt.name && opt.args) || []),
|
|
204
|
+
(0, colors_1.dimGrey)('took ' + (0, js_lib_1._since)(started)),
|
|
205
|
+
]
|
|
206
|
+
.filter(Boolean)
|
|
207
|
+
.join(' '));
|
|
196
208
|
}
|
|
197
209
|
}
|
|
198
210
|
exports.exec2 = new Exec2();
|
package/package.json
CHANGED
package/src/util/exec2.ts
CHANGED
|
@@ -68,8 +68,10 @@ class Exec2 {
|
|
|
68
68
|
const p = cp.spawn(cmd, opt.args || [], {
|
|
69
69
|
shell,
|
|
70
70
|
cwd,
|
|
71
|
-
env
|
|
72
|
-
|
|
71
|
+
env: {
|
|
72
|
+
...env,
|
|
73
|
+
...(opt.passProcessEnv ? process.env : {}),
|
|
74
|
+
},
|
|
73
75
|
})
|
|
74
76
|
|
|
75
77
|
p.stdout.on('data', data => {
|
|
@@ -130,8 +132,10 @@ class Exec2 {
|
|
|
130
132
|
stdio: 'inherit',
|
|
131
133
|
shell,
|
|
132
134
|
cwd,
|
|
133
|
-
env
|
|
134
|
-
|
|
135
|
+
env: {
|
|
136
|
+
...env,
|
|
137
|
+
...(opt.passProcessEnv ? process.env : {}),
|
|
138
|
+
},
|
|
135
139
|
})
|
|
136
140
|
|
|
137
141
|
this.logFinish(cmd, opt, started)
|
|
@@ -172,8 +176,10 @@ class Exec2 {
|
|
|
172
176
|
// shell: undefined,
|
|
173
177
|
cwd,
|
|
174
178
|
timeout,
|
|
175
|
-
env
|
|
176
|
-
|
|
179
|
+
env: {
|
|
180
|
+
...env,
|
|
181
|
+
...(opt.passProcessEnv ? process.env : {}),
|
|
182
|
+
},
|
|
177
183
|
})
|
|
178
184
|
.trim()
|
|
179
185
|
} catch (err) {
|
|
@@ -218,7 +224,15 @@ class Exec2 {
|
|
|
218
224
|
): void {
|
|
219
225
|
if (!opt.logFinish && !opt.log) return
|
|
220
226
|
|
|
221
|
-
console.log(
|
|
227
|
+
console.log(
|
|
228
|
+
[
|
|
229
|
+
white(opt.name || cmd),
|
|
230
|
+
...((!opt.name && (opt as SpawnOptions).args) || []),
|
|
231
|
+
dimGrey('took ' + _since(started)),
|
|
232
|
+
]
|
|
233
|
+
.filter(Boolean)
|
|
234
|
+
.join(' '),
|
|
235
|
+
)
|
|
222
236
|
}
|
|
223
237
|
}
|
|
224
238
|
|
|
@@ -297,6 +311,11 @@ export interface SpawnOptions {
|
|
|
297
311
|
cwd?: string
|
|
298
312
|
|
|
299
313
|
env?: AnyObject
|
|
314
|
+
/**
|
|
315
|
+
* Defaults to false for security reasons.
|
|
316
|
+
* Set to true to pass `process.env` to the spawned process.
|
|
317
|
+
*/
|
|
318
|
+
passProcessEnv?: boolean
|
|
300
319
|
}
|
|
301
320
|
|
|
302
321
|
export interface ExecOptions {
|
|
@@ -323,4 +342,9 @@ export interface ExecOptions {
|
|
|
323
342
|
timeout?: NumberOfMilliseconds
|
|
324
343
|
|
|
325
344
|
env?: AnyObject
|
|
345
|
+
/**
|
|
346
|
+
* Defaults to false for security reasons.
|
|
347
|
+
* Set to true to pass `process.env` to the spawned process.
|
|
348
|
+
*/
|
|
349
|
+
passProcessEnv?: boolean
|
|
326
350
|
}
|