runallx 1.0.0 → 1.0.1
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/bin/runallx.js +18 -7
- package/package.json +1 -1
- package/readme.md +8 -0
package/bin/runallx.js
CHANGED
|
@@ -42,7 +42,7 @@ console.log(`runall: starting ${scriptNames.join(', ')}`);
|
|
|
42
42
|
|
|
43
43
|
const children = [];
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
function spawnScript(name) {
|
|
46
46
|
const args = pm === 'npm' ? ['run', name] : [name];
|
|
47
47
|
|
|
48
48
|
const child = spawn(pm, args, {
|
|
@@ -51,23 +51,34 @@ scriptNames.forEach((name) => {
|
|
|
51
51
|
env: process.env,
|
|
52
52
|
});
|
|
53
53
|
|
|
54
|
-
readline.createInterface({ input: child.stdout }).on('line',
|
|
54
|
+
readline.createInterface({ input: child.stdout }).on('line', line => {
|
|
55
55
|
console.log(`[${name}] ${line}`);
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
-
readline.createInterface({ input: child.stderr }).on('line',
|
|
58
|
+
readline.createInterface({ input: child.stderr }).on('line', line => {
|
|
59
59
|
console.error(`[${name}] ${line}`);
|
|
60
60
|
});
|
|
61
61
|
|
|
62
|
-
child.on('exit', (code) => {
|
|
63
|
-
console.log(`[${name}] exited with code ${code}`);
|
|
62
|
+
child.on('exit', (code, signal) => {
|
|
63
|
+
console.log(`[${name}] exited with code ${code} signal ${signal}`);
|
|
64
|
+
setTimeout(() => {
|
|
65
|
+
console.log(`[${name}] restarting...`);
|
|
66
|
+
const newChild = spawnScript(name);
|
|
67
|
+
const index = children.findIndex(c => c.name === name);
|
|
68
|
+
if (index !== -1) children[index].child = newChild;
|
|
69
|
+
}, 1500);
|
|
64
70
|
});
|
|
65
71
|
|
|
66
|
-
|
|
72
|
+
return child;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
scriptNames.forEach(name => {
|
|
76
|
+
const child = spawnScript(name);
|
|
77
|
+
children.push({ name, child });
|
|
67
78
|
});
|
|
68
79
|
|
|
69
80
|
process.on('SIGINT', () => {
|
|
70
81
|
console.log('\nrunall: stopping all processes...');
|
|
71
|
-
children.forEach(
|
|
82
|
+
children.forEach(c => c.child.kill('SIGINT'));
|
|
72
83
|
process.exit(0);
|
|
73
84
|
});
|
package/package.json
CHANGED
package/readme.md
CHANGED