@naturalcycles/nodejs-lib 13.34.3 → 13.34.4

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.
@@ -68,7 +68,7 @@ declare class Exec2 {
68
68
  * Defaults:
69
69
  *
70
70
  * shell: true
71
- * log: true
71
+ * log: false
72
72
  */
73
73
  exec(cmd: string, opt?: ExecOptions): string;
74
74
  throwOnNonZeroExitCode(o: SpawnOutput): void;
@@ -50,6 +50,8 @@ class Exec2 {
50
50
  async spawnAsync(cmd, opt = {}) {
51
51
  const { shell = true, printWhileRunning = true, collectOutputWhileRunning = true, throwOnNonZeroCode = true, cwd, env, passProcessEnv = true, forceColor = colors_1.hasColors, } = opt;
52
52
  opt.log ??= printWhileRunning; // by default log should be true, as we are printing the output
53
+ opt.logStart ??= opt.log;
54
+ opt.logFinish ??= opt.log;
53
55
  const started = Date.now();
54
56
  this.logStart(cmd, opt);
55
57
  let stdout = '';
@@ -116,6 +118,8 @@ class Exec2 {
116
118
  spawn(cmd, opt = {}) {
117
119
  const { shell = true, cwd, env, passProcessEnv = true, forceColor = colors_1.hasColors } = opt;
118
120
  opt.log ??= true; // by default log should be true, as we are printing the output
121
+ opt.logStart ??= opt.log;
122
+ opt.logFinish ??= opt.log;
119
123
  const started = Date.now();
120
124
  this.logStart(cmd, opt);
121
125
  // console.log('') // 1-line padding before the output
@@ -152,12 +156,14 @@ class Exec2 {
152
156
  * Defaults:
153
157
  *
154
158
  * shell: true
155
- * log: true
159
+ * log: false
156
160
  */
157
161
  exec(cmd, opt = {}) {
162
+ const { cwd, env, passProcessEnv = true, timeout } = opt;
163
+ opt.logStart ??= opt.log ?? false;
164
+ opt.logFinish ??= opt.log ?? false;
158
165
  const started = Date.now();
159
166
  this.logStart(cmd, opt);
160
- const { cwd, env, passProcessEnv = true, timeout } = opt;
161
167
  try {
162
168
  const s = node_child_process_1.default
163
169
  .execSync(cmd, {
@@ -195,7 +201,7 @@ class Exec2 {
195
201
  }
196
202
  }
197
203
  logStart(cmd, opt) {
198
- if (!opt.logStart && !opt.log)
204
+ if (!opt.logStart)
199
205
  return;
200
206
  console.log([
201
207
  (0, colors_1.dimGrey)(...Object.entries(opt.env || {}).map(([k, v]) => [k, v].join('='))),
@@ -206,7 +212,7 @@ class Exec2 {
206
212
  .join(' '));
207
213
  }
208
214
  logFinish(cmd, opt, started, isSuccessful) {
209
- if (isSuccessful && !opt.logFinish && !opt.log)
215
+ if (isSuccessful && !opt.logFinish)
210
216
  return;
211
217
  console.log([
212
218
  (0, colors_1.white)(opt.name || cmd),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/nodejs-lib",
3
- "version": "13.34.3",
3
+ "version": "13.34.4",
4
4
  "scripts": {
5
5
  "prepare": "husky",
6
6
  "build": "dev-lib build",
package/src/util/exec2.ts CHANGED
@@ -62,6 +62,8 @@ class Exec2 {
62
62
  forceColor = hasColors,
63
63
  } = opt
64
64
  opt.log ??= printWhileRunning // by default log should be true, as we are printing the output
65
+ opt.logStart ??= opt.log
66
+ opt.logFinish ??= opt.log
65
67
  const started = Date.now()
66
68
  this.logStart(cmd, opt)
67
69
  let stdout = ''
@@ -133,6 +135,8 @@ class Exec2 {
133
135
  spawn(cmd: string, opt: SpawnOptions = {}): void {
134
136
  const { shell = true, cwd, env, passProcessEnv = true, forceColor = hasColors } = opt
135
137
  opt.log ??= true // by default log should be true, as we are printing the output
138
+ opt.logStart ??= opt.log
139
+ opt.logFinish ??= opt.log
136
140
  const started = Date.now()
137
141
  this.logStart(cmd, opt)
138
142
  // console.log('') // 1-line padding before the output
@@ -173,12 +177,14 @@ class Exec2 {
173
177
  * Defaults:
174
178
  *
175
179
  * shell: true
176
- * log: true
180
+ * log: false
177
181
  */
178
182
  exec(cmd: string, opt: ExecOptions = {}): string {
183
+ const { cwd, env, passProcessEnv = true, timeout } = opt
184
+ opt.logStart ??= opt.log ?? false
185
+ opt.logFinish ??= opt.log ?? false
179
186
  const started = Date.now()
180
187
  this.logStart(cmd, opt)
181
- const { cwd, env, passProcessEnv = true, timeout } = opt
182
188
 
183
189
  try {
184
190
  const s = cp
@@ -219,7 +225,7 @@ class Exec2 {
219
225
  }
220
226
 
221
227
  private logStart(cmd: string, opt: SpawnOptions | ExecOptions): void {
222
- if (!opt.logStart && !opt.log) return
228
+ if (!opt.logStart) return
223
229
 
224
230
  console.log(
225
231
  [
@@ -238,7 +244,7 @@ class Exec2 {
238
244
  started: UnixTimestampMillisNumber,
239
245
  isSuccessful: boolean,
240
246
  ): void {
241
- if (isSuccessful && !opt.logFinish && !opt.log) return
247
+ if (isSuccessful && !opt.logFinish) return
242
248
 
243
249
  console.log(
244
250
  [