@flowscripter/dynamic-cli-framework 2.3.0 → 2.3.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.
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { PrinterService, ShutdownService, SpawnOptions, SpawnResult, SpawnService } from "@flowscripter/dynamic-cli-framework-api";
|
|
2
|
+
/**
|
|
3
|
+
* On Windows, batch-file shims (e.g. `npm.cmd`, `bun.cmd`) cannot be launched directly via
|
|
4
|
+
* `CreateProcess` - they must be run through `cmd.exe /c`. Resolve the command through the shell
|
|
5
|
+
* in that case; leave it untouched on other platforms.
|
|
6
|
+
*/
|
|
7
|
+
export declare function resolveForPlatform(command: ReadonlyArray<string>): string[];
|
|
2
8
|
export default class DefaultSpawnService implements SpawnService {
|
|
3
9
|
#private;
|
|
4
10
|
setDependencies(printerService: PrinterService, shutdownService: ShutdownService): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DefaultSpawnService.d.ts","sourceRoot":"","sources":["../../../../src/service/spawn/DefaultSpawnService.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DefaultSpawnService.d.ts","sourceRoot":"","sources":["../../../../src/service/spawn/DefaultSpawnService.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EACf,YAAY,EACZ,WAAW,EACX,YAAY,EACb,MAAM,yCAAyC,CAAC;AAOjD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,MAAM,EAAE,CAa3E;AAED,MAAM,CAAC,OAAO,OAAO,mBAAoB,YAAW,YAAY;;IAIvD,eAAe,CAAC,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,eAAe,GAAG,IAAI;IAkCjF,KAAK,CAChB,OAAO,EAAE,aAAa,CAAC,MAAM,CAAC,EAC9B,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC,WAAW,CAAC;CAiExB"}
|
|
@@ -1,6 +1,26 @@
|
|
|
1
|
+
import process from "node:process";
|
|
1
2
|
import getLogger from "../../util/logger.js";
|
|
2
3
|
const logger = getLogger("DefaultSpawnService");
|
|
3
4
|
const SHUTDOWN_GRACE_PERIOD_MS = 5000;
|
|
5
|
+
/**
|
|
6
|
+
* On Windows, batch-file shims (e.g. `npm.cmd`, `bun.cmd`) cannot be launched directly via
|
|
7
|
+
* `CreateProcess` - they must be run through `cmd.exe /c`. Resolve the command through the shell
|
|
8
|
+
* in that case; leave it untouched on other platforms.
|
|
9
|
+
*/
|
|
10
|
+
export function resolveForPlatform(command) {
|
|
11
|
+
if (process.platform !== "win32") {
|
|
12
|
+
return [...command];
|
|
13
|
+
}
|
|
14
|
+
const [bin, ...args] = command;
|
|
15
|
+
if (bin === undefined) {
|
|
16
|
+
return [...command];
|
|
17
|
+
}
|
|
18
|
+
const resolved = Bun.which(bin) ?? bin;
|
|
19
|
+
if (!/\.(cmd|bat)$/i.test(resolved)) {
|
|
20
|
+
return [resolved, ...args];
|
|
21
|
+
}
|
|
22
|
+
return ["cmd.exe", "/d", "/s", "/c", resolved, ...args];
|
|
23
|
+
}
|
|
4
24
|
export default class DefaultSpawnService {
|
|
5
25
|
#printerService;
|
|
6
26
|
#shutdownService;
|
|
@@ -46,7 +66,7 @@ export default class DefaultSpawnService {
|
|
|
46
66
|
}
|
|
47
67
|
let proc;
|
|
48
68
|
try {
|
|
49
|
-
proc = Bun.spawn(
|
|
69
|
+
proc = Bun.spawn(resolveForPlatform(command), {
|
|
50
70
|
cwd: options.cwd,
|
|
51
71
|
stdin: stdio === "wrapped" ? "ignore" : "inherit",
|
|
52
72
|
stdout: stdio === "wrapped" ? "pipe" : "inherit",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowscripter/dynamic-cli-framework",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.1",
|
|
4
4
|
"description": "A framework for developing CLI applications which supports dynamic discovery and installation of new commands",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bun",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@flowscripter/dynamic-cli-framework-api": "^1.2.0",
|
|
52
|
-
"@flowscripter/dynamic-plugin-framework": "1.11.
|
|
52
|
+
"@flowscripter/dynamic-plugin-framework": "1.11.1",
|
|
53
53
|
"emphasize": "^7.0.0",
|
|
54
54
|
"fastest-levenshtein": "^1.0.16",
|
|
55
55
|
"figlet": "^1.11.0",
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import process from "node:process";
|
|
1
2
|
import type {
|
|
2
3
|
PrinterService,
|
|
3
4
|
ShutdownService,
|
|
@@ -11,6 +12,26 @@ const logger = getLogger("DefaultSpawnService");
|
|
|
11
12
|
|
|
12
13
|
const SHUTDOWN_GRACE_PERIOD_MS = 5000;
|
|
13
14
|
|
|
15
|
+
/**
|
|
16
|
+
* On Windows, batch-file shims (e.g. `npm.cmd`, `bun.cmd`) cannot be launched directly via
|
|
17
|
+
* `CreateProcess` - they must be run through `cmd.exe /c`. Resolve the command through the shell
|
|
18
|
+
* in that case; leave it untouched on other platforms.
|
|
19
|
+
*/
|
|
20
|
+
export function resolveForPlatform(command: ReadonlyArray<string>): string[] {
|
|
21
|
+
if (process.platform !== "win32") {
|
|
22
|
+
return [...command];
|
|
23
|
+
}
|
|
24
|
+
const [bin, ...args] = command;
|
|
25
|
+
if (bin === undefined) {
|
|
26
|
+
return [...command];
|
|
27
|
+
}
|
|
28
|
+
const resolved = Bun.which(bin) ?? bin;
|
|
29
|
+
if (!/\.(cmd|bat)$/i.test(resolved)) {
|
|
30
|
+
return [resolved, ...args];
|
|
31
|
+
}
|
|
32
|
+
return ["cmd.exe", "/d", "/s", "/c", resolved, ...args];
|
|
33
|
+
}
|
|
34
|
+
|
|
14
35
|
export default class DefaultSpawnService implements SpawnService {
|
|
15
36
|
#printerService: PrinterService | undefined;
|
|
16
37
|
#shutdownService: ShutdownService | undefined;
|
|
@@ -68,7 +89,7 @@ export default class DefaultSpawnService implements SpawnService {
|
|
|
68
89
|
|
|
69
90
|
let proc;
|
|
70
91
|
try {
|
|
71
|
-
proc = Bun.spawn(
|
|
92
|
+
proc = Bun.spawn(resolveForPlatform(command), {
|
|
72
93
|
cwd: options.cwd,
|
|
73
94
|
stdin: stdio === "wrapped" ? "ignore" : "inherit",
|
|
74
95
|
stdout: stdio === "wrapped" ? "pipe" : "inherit",
|