@serviceme/devtools-core 0.0.4 → 0.0.5

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/index.js CHANGED
@@ -50,6 +50,26 @@ var import_devtools_protocol2 = require("@serviceme/devtools-protocol");
50
50
 
51
51
  // src/process/runCommand.ts
52
52
  var import_node_child_process = require("child_process");
53
+ function terminateCommandProcess(child) {
54
+ if (child.killed) {
55
+ return;
56
+ }
57
+ if (process.platform === "win32" && child.pid) {
58
+ const killProcess = (0, import_node_child_process.spawn)(
59
+ "taskkill",
60
+ ["/pid", String(child.pid), "/T", "/F"],
61
+ {
62
+ stdio: "ignore",
63
+ windowsHide: true
64
+ }
65
+ );
66
+ killProcess.once("error", () => {
67
+ child.kill();
68
+ });
69
+ return;
70
+ }
71
+ child.kill("SIGTERM");
72
+ }
53
73
  async function runCommand(command, options = {}) {
54
74
  return new Promise((resolve, reject) => {
55
75
  const child = (0, import_node_child_process.spawn)(command, options.args ?? [], {
@@ -110,7 +130,7 @@ async function runCommand(command, options = {}) {
110
130
  if (options.timeoutMs) {
111
131
  timeoutId = setTimeout(() => {
112
132
  finish(() => {
113
- child.kill("SIGTERM");
133
+ terminateCommandProcess(child);
114
134
  const error = new Error(
115
135
  `Command timed out after ${String(options.timeoutMs)}ms.`
116
136
  );
@@ -1106,12 +1126,17 @@ var ProjectTools = class {
1106
1126
  );
1107
1127
  let updatedCount = 0;
1108
1128
  if (isWindows) {
1109
- for (const scriptPath of scripts.filter((script) => script.endsWith(".ps1"))) {
1129
+ for (const scriptPath of scripts.filter(
1130
+ (script) => script.endsWith(".ps1")
1131
+ )) {
1110
1132
  try {
1111
- await runCommand(`powershell -Command "Unblock-File -Path '${scriptPath}'"`, {
1112
- cwd: workspacePath,
1113
- shell: true
1114
- });
1133
+ await runCommand(
1134
+ `powershell -Command "Unblock-File -Path '${scriptPath}'"`,
1135
+ {
1136
+ cwd: workspacePath,
1137
+ shell: true
1138
+ }
1139
+ );
1115
1140
  updatedCount += 1;
1116
1141
  } catch {
1117
1142
  }
@@ -1193,7 +1218,9 @@ var ProjectTools = class {
1193
1218
  if (directoryNames.length === 1) {
1194
1219
  return directoryNames[0] ?? null;
1195
1220
  }
1196
- const exactMatch = directoryNames.find((directoryName) => directoryName === expectedDirName);
1221
+ const exactMatch = directoryNames.find(
1222
+ (directoryName) => directoryName === expectedDirName
1223
+ );
1197
1224
  if (exactMatch) {
1198
1225
  return exactMatch;
1199
1226
  }
package/dist/index.mjs CHANGED
@@ -13,6 +13,26 @@ import { createServicemeError } from "@serviceme/devtools-protocol";
13
13
 
14
14
  // src/process/runCommand.ts
15
15
  import { spawn } from "child_process";
16
+ function terminateCommandProcess(child) {
17
+ if (child.killed) {
18
+ return;
19
+ }
20
+ if (process.platform === "win32" && child.pid) {
21
+ const killProcess = spawn(
22
+ "taskkill",
23
+ ["/pid", String(child.pid), "/T", "/F"],
24
+ {
25
+ stdio: "ignore",
26
+ windowsHide: true
27
+ }
28
+ );
29
+ killProcess.once("error", () => {
30
+ child.kill();
31
+ });
32
+ return;
33
+ }
34
+ child.kill("SIGTERM");
35
+ }
16
36
  async function runCommand(command, options = {}) {
17
37
  return new Promise((resolve, reject) => {
18
38
  const child = spawn(command, options.args ?? [], {
@@ -73,7 +93,7 @@ async function runCommand(command, options = {}) {
73
93
  if (options.timeoutMs) {
74
94
  timeoutId = setTimeout(() => {
75
95
  finish(() => {
76
- child.kill("SIGTERM");
96
+ terminateCommandProcess(child);
77
97
  const error = new Error(
78
98
  `Command timed out after ${String(options.timeoutMs)}ms.`
79
99
  );
@@ -1085,12 +1105,17 @@ var ProjectTools = class {
1085
1105
  );
1086
1106
  let updatedCount = 0;
1087
1107
  if (isWindows) {
1088
- for (const scriptPath of scripts.filter((script) => script.endsWith(".ps1"))) {
1108
+ for (const scriptPath of scripts.filter(
1109
+ (script) => script.endsWith(".ps1")
1110
+ )) {
1089
1111
  try {
1090
- await runCommand(`powershell -Command "Unblock-File -Path '${scriptPath}'"`, {
1091
- cwd: workspacePath,
1092
- shell: true
1093
- });
1112
+ await runCommand(
1113
+ `powershell -Command "Unblock-File -Path '${scriptPath}'"`,
1114
+ {
1115
+ cwd: workspacePath,
1116
+ shell: true
1117
+ }
1118
+ );
1094
1119
  updatedCount += 1;
1095
1120
  } catch {
1096
1121
  }
@@ -1172,7 +1197,9 @@ var ProjectTools = class {
1172
1197
  if (directoryNames.length === 1) {
1173
1198
  return directoryNames[0] ?? null;
1174
1199
  }
1175
- const exactMatch = directoryNames.find((directoryName) => directoryName === expectedDirName);
1200
+ const exactMatch = directoryNames.find(
1201
+ (directoryName) => directoryName === expectedDirName
1202
+ );
1176
1203
  if (exactMatch) {
1177
1204
  return exactMatch;
1178
1205
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serviceme/devtools-core",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "Reusable Node.js core capabilities powering the SERVICEME CLI and integrations.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "repository": {
@@ -36,7 +36,7 @@
36
36
  "comment-json": "^4.5.1",
37
37
  "json5": "^2.2.3",
38
38
  "yauzl": "^3.2.0",
39
- "@serviceme/devtools-protocol": "0.0.4"
39
+ "@serviceme/devtools-protocol": "0.0.5"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/node": "^24",