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 CHANGED
@@ -42,7 +42,7 @@ console.log(`runall: starting ${scriptNames.join(', ')}`);
42
42
 
43
43
  const children = [];
44
44
 
45
- scriptNames.forEach((name) => {
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', (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', (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
- children.push(child);
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((c) => c.kill('SIGINT'));
82
+ children.forEach(c => c.child.kill('SIGINT'));
72
83
  process.exit(0);
73
84
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "runallx",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "run all package.json",
5
5
  "keywords": [
6
6
  "cli",
package/readme.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # RUNALL
2
2
 
3
+ ## install
4
+
5
+ ```
6
+ npm i -g runallx
7
+ ```
8
+
3
9
  ## example
4
10
 
5
11
  ```package.json
@@ -12,5 +18,7 @@
12
18
  **run**
13
19
  ```
14
20
  runallx yarn dev-api dev-tcp
21
+ runallx pnpm dev-api dev-tcp
22
+ runallx npm dev-api dev-tcp
15
23
  ```
16
24