@naturalcycles/nodejs-lib 13.34.2 → 13.34.3
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.js +8 -8
- package/package.json +1 -1
- package/src/util/exec2.ts +9 -7
package/dist/util/exec2.js
CHANGED
|
@@ -48,13 +48,13 @@ class Exec2 {
|
|
|
48
48
|
* log: true
|
|
49
49
|
*/
|
|
50
50
|
async spawnAsync(cmd, opt = {}) {
|
|
51
|
+
const { shell = true, printWhileRunning = true, collectOutputWhileRunning = true, throwOnNonZeroCode = true, cwd, env, passProcessEnv = true, forceColor = colors_1.hasColors, } = opt;
|
|
52
|
+
opt.log ??= printWhileRunning; // by default log should be true, as we are printing the output
|
|
51
53
|
const started = Date.now();
|
|
52
54
|
this.logStart(cmd, opt);
|
|
53
|
-
const { shell = true, printWhileRunning = true, collectOutputWhileRunning = true, throwOnNonZeroCode = true, cwd, env, passProcessEnv = true, forceColor = colors_1.hasColors, } = opt;
|
|
54
55
|
let stdout = '';
|
|
55
56
|
let stderr = '';
|
|
56
|
-
if (printWhileRunning)
|
|
57
|
-
console.log(''); // 1-line padding before the output
|
|
57
|
+
// if (printWhileRunning) console.log('') // 1-line padding before the output
|
|
58
58
|
return await new Promise((resolve, reject) => {
|
|
59
59
|
const p = node_child_process_1.default.spawn(cmd, opt.args || [], {
|
|
60
60
|
shell,
|
|
@@ -84,8 +84,7 @@ class Exec2 {
|
|
|
84
84
|
}
|
|
85
85
|
});
|
|
86
86
|
p.on('close', code => {
|
|
87
|
-
if (printWhileRunning)
|
|
88
|
-
console.log(''); // 1-line padding after the output
|
|
87
|
+
// if (printWhileRunning) console.log('') // 1-line padding after the output
|
|
89
88
|
const isSuccessful = !code;
|
|
90
89
|
this.logFinish(cmd, opt, started, isSuccessful);
|
|
91
90
|
const exitCode = code || 0;
|
|
@@ -115,10 +114,11 @@ class Exec2 {
|
|
|
115
114
|
* log: true
|
|
116
115
|
*/
|
|
117
116
|
spawn(cmd, opt = {}) {
|
|
117
|
+
const { shell = true, cwd, env, passProcessEnv = true, forceColor = colors_1.hasColors } = opt;
|
|
118
|
+
opt.log ??= true; // by default log should be true, as we are printing the output
|
|
118
119
|
const started = Date.now();
|
|
119
120
|
this.logStart(cmd, opt);
|
|
120
|
-
|
|
121
|
-
console.log(''); // 1-line padding before the output
|
|
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',
|
|
124
124
|
stdio: 'inherit',
|
|
@@ -130,7 +130,7 @@ class Exec2 {
|
|
|
130
130
|
...env,
|
|
131
131
|
},
|
|
132
132
|
});
|
|
133
|
-
console.log('')
|
|
133
|
+
// console.log('') // 1-line padding after the output
|
|
134
134
|
const isSuccessful = !r.error && !r.status;
|
|
135
135
|
this.logFinish(cmd, opt, started, isSuccessful);
|
|
136
136
|
if (r.error) {
|
package/package.json
CHANGED
package/src/util/exec2.ts
CHANGED
|
@@ -51,8 +51,6 @@ class Exec2 {
|
|
|
51
51
|
* log: true
|
|
52
52
|
*/
|
|
53
53
|
async spawnAsync(cmd: string, opt: SpawnAsyncOptions = {}): Promise<SpawnOutput> {
|
|
54
|
-
const started = Date.now()
|
|
55
|
-
this.logStart(cmd, opt)
|
|
56
54
|
const {
|
|
57
55
|
shell = true,
|
|
58
56
|
printWhileRunning = true,
|
|
@@ -63,10 +61,13 @@ class Exec2 {
|
|
|
63
61
|
passProcessEnv = true,
|
|
64
62
|
forceColor = hasColors,
|
|
65
63
|
} = opt
|
|
64
|
+
opt.log ??= printWhileRunning // by default log should be true, as we are printing the output
|
|
65
|
+
const started = Date.now()
|
|
66
|
+
this.logStart(cmd, opt)
|
|
66
67
|
let stdout = ''
|
|
67
68
|
let stderr = ''
|
|
68
69
|
|
|
69
|
-
if (printWhileRunning) console.log('') // 1-line padding before the output
|
|
70
|
+
// if (printWhileRunning) console.log('') // 1-line padding before the output
|
|
70
71
|
|
|
71
72
|
return await new Promise<SpawnOutput>((resolve, reject) => {
|
|
72
73
|
const p = cp.spawn(cmd, opt.args || [], {
|
|
@@ -99,7 +100,7 @@ class Exec2 {
|
|
|
99
100
|
})
|
|
100
101
|
|
|
101
102
|
p.on('close', code => {
|
|
102
|
-
if (printWhileRunning) console.log('') // 1-line padding after the output
|
|
103
|
+
// if (printWhileRunning) console.log('') // 1-line padding after the output
|
|
103
104
|
const isSuccessful = !code
|
|
104
105
|
this.logFinish(cmd, opt, started, isSuccessful)
|
|
105
106
|
const exitCode = code || 0
|
|
@@ -130,10 +131,11 @@ class Exec2 {
|
|
|
130
131
|
* log: true
|
|
131
132
|
*/
|
|
132
133
|
spawn(cmd: string, opt: SpawnOptions = {}): void {
|
|
134
|
+
const { shell = true, cwd, env, passProcessEnv = true, forceColor = hasColors } = opt
|
|
135
|
+
opt.log ??= true // by default log should be true, as we are printing the output
|
|
133
136
|
const started = Date.now()
|
|
134
137
|
this.logStart(cmd, opt)
|
|
135
|
-
|
|
136
|
-
console.log('') // 1-line padding before the output
|
|
138
|
+
// console.log('') // 1-line padding before the output
|
|
137
139
|
|
|
138
140
|
const r = cp.spawnSync(cmd, opt.args, {
|
|
139
141
|
encoding: 'utf8',
|
|
@@ -147,7 +149,7 @@ class Exec2 {
|
|
|
147
149
|
},
|
|
148
150
|
})
|
|
149
151
|
|
|
150
|
-
console.log('') // 1-line padding after the output
|
|
152
|
+
// console.log('') // 1-line padding after the output
|
|
151
153
|
const isSuccessful = !r.error && !r.status
|
|
152
154
|
this.logFinish(cmd, opt, started, isSuccessful)
|
|
153
155
|
|