cob-cli 2.46.0-beta.6 → 2.46.0-beta.7

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.
@@ -24,7 +24,7 @@ async function test (args) {
24
24
  await cmdEnv.applyCurrentCommandEnvironmentChanges()
25
25
  }
26
26
  spawned = await customUIsContinuosReload(cmdEnv, args.dashboard)
27
-
27
+
28
28
  let key;
29
29
  do {
30
30
  key = await getKeypress()
@@ -37,11 +37,8 @@ async function test (args) {
37
37
  } finally {
38
38
  restoreChanges && await restoreChanges()
39
39
  cmdEnv && await cmdEnv.unApplyCurrentCommandEnvironmentChanges() // Repõe as configurações
40
- if(spawned) spawned.forEach( spawn => {
41
- spawn.kill("SIGINT");
42
- })
43
- process.kill(process.pid, "SIGINT");
44
- // Dá tempo aos subprocessos para morrer
40
+ await spawned.stop();
41
+ // Dá tempo aos subprocessos para morrer (acho que já não é preciso)
45
42
  setTimeout(() => {
46
43
  if(!error) {
47
44
  console.log( "\n"
@@ -2,12 +2,17 @@ const execa = require('execa');
2
2
  const path = require('path');
3
3
  const concurrently = require('concurrently');
4
4
  const fs= require('fs');
5
+ const util = require('util');
6
+ const child_process = require('child_process');
7
+ const exec = util.promisify(child_process.exec);
8
+
5
9
 
6
10
  async function customUIsContinuosReload(cmdEnv, dashboard) {
7
11
  process.env.dash_dir = dashboard
8
12
  process.env.server = "https://" + cmdEnv.server
9
13
 
10
14
  let commands = []
15
+ let isStopping = false;
11
16
 
12
17
  let dashboardPath = path.resolve(".") + "/recordm/customUI/" + dashboard;
13
18
  let dashboardPathIsDirectory = false;
@@ -54,11 +59,33 @@ async function customUIsContinuosReload(cmdEnv, dashboard) {
54
59
  killOthers: ['failure', 'success']
55
60
  });
56
61
 
62
+ const stopEverything = async function(){
63
+ isStopping = true;
64
+ for(const spawn of conc.commands) {
65
+ // console.log("\n killing spawn [" + spawn.pid + "] " + spawn.command )
66
+
67
+ // win32 seems to not kill child processes, and concurrently wraps executions with a cmd.exe shell
68
+ if (process.platform === 'win32') {
69
+ try {
70
+ await exec(`taskkill /PID ${spawn.pid} /T /F`)
71
+ } catch (err) {
72
+ console.error("error trying to taskkill process tree", err)
73
+ }
74
+
75
+ } else {
76
+ spawn.kill("SIGINT");
77
+ }
78
+ }
79
+ }
80
+
57
81
  conc.result.catch( _err => {
58
- console.log("press any key " + "(except enter)".red + " to stop the tests... \n ")
59
- process.kill(process.pid, "SIGINT");
82
+ if(isStopping) return;
83
+
84
+ stopEverything();
60
85
  });
61
86
 
62
- return conc.commands;
87
+ return {
88
+ stop: stopEverything
89
+ };
63
90
  }
64
91
  exports.customUIsContinuosReload = customUIsContinuosReload;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cob-cli",
3
- "version": "2.46.0-beta.6",
3
+ "version": "2.46.0-beta.7",
4
4
  "description": "A command line utility to help Cult of Bits partners develop with higher speed and reusing common code and best practices.",
5
5
  "preferGlobal": true,
6
6
  "repository": {