cob-cli 2.46.0-beta.5 → 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.
@@ -10,6 +10,7 @@ const { checkRepoVersion } = require("../commands/upgradeRepo");
10
10
  async function test (args) {
11
11
  let restoreChanges, error = "";
12
12
  let cmdEnv
13
+ let spawned
13
14
  try {
14
15
  checkRepoVersion()
15
16
  console.log("Start testing… ")
@@ -22,8 +23,8 @@ async function test (args) {
22
23
  } else {
23
24
  await cmdEnv.applyCurrentCommandEnvironmentChanges()
24
25
  }
25
- customUIsContinuosReload(cmdEnv, args.dashboard)
26
-
26
+ spawned = await customUIsContinuosReload(cmdEnv, args.dashboard)
27
+
27
28
  let key;
28
29
  do {
29
30
  key = await getKeypress()
@@ -36,8 +37,8 @@ async function test (args) {
36
37
  } finally {
37
38
  restoreChanges && await restoreChanges()
38
39
  cmdEnv && await cmdEnv.unApplyCurrentCommandEnvironmentChanges() // Repõe as configurações
39
- process.kill(process.pid, "SIGINT");
40
- // Dá tempo aos subprocessos para morrer
40
+ await spawned.stop();
41
+ // Dá tempo aos subprocessos para morrer (acho que já não é preciso)
41
42
  setTimeout(() => {
42
43
  if(!error) {
43
44
  console.log( "\n"
@@ -49,4 +50,4 @@ async function test (args) {
49
50
  }, 2000);
50
51
  }
51
52
  }
52
- module.exports = test
53
+ module.exports = test
@@ -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;
@@ -47,14 +52,40 @@ async function customUIsContinuosReload(cmdEnv, dashboard) {
47
52
  prefixColor: "blue"
48
53
  })
49
54
 
50
- concurrently( commands, {
55
+ const conc = concurrently( commands, {
51
56
  prefix: 'name',
52
57
  inputStream: process.stdin,
53
58
  handleInput: false,
54
59
  killOthers: ['failure', 'success']
55
- }).catch( err => {
56
- console.log("press any key " + "(except enter)".red + " to stop the tests... \n ")
57
- process.kill(process.pid, "SIGINT");
58
- })
60
+ });
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
+
81
+ conc.result.catch( _err => {
82
+ if(isStopping) return;
83
+
84
+ stopEverything();
85
+ });
86
+
87
+ return {
88
+ stop: stopEverything
89
+ };
59
90
  }
60
- exports.customUIsContinuosReload = customUIsContinuosReload;
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.5",
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": {
@@ -22,7 +22,7 @@
22
22
  "cmd-line-importer": "^1.0.0",
23
23
  "colors": "^1.4.0",
24
24
  "commander": "^5.1.0",
25
- "concurrently": "^5.3.0",
25
+ "concurrently": "^8.0.0",
26
26
  "execa": "^4.0.3",
27
27
  "fast-glob": "^3.2.5",
28
28
  "file-cookie-store": "^0.2.1",
package/.tool-versions DELETED
@@ -1 +0,0 @@
1
- nodejs 16.20.2
package/tsconfig.json DELETED
@@ -1,10 +0,0 @@
1
- {
2
- compilerOptions": {
3
- "module": "commonjs",
4
- "target": "ESNext",
5
- "checkJs": false
6
- },
7
- "exclude": [
8
- "node_modules"
9
- ]
10
- }