@shareai-lab/kode 1.0.99 → 1.0.101
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/cli.js +16 -1
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -9,7 +9,9 @@ const cliPath = path.join(__dirname, 'src', 'entrypoints', 'cli.tsx');
|
|
|
9
9
|
|
|
10
10
|
// Resolve tsx from this package directory (stable across global installs)
|
|
11
11
|
let tsxImportPath = null;
|
|
12
|
+
let tsxCliPath = null;
|
|
12
13
|
try { tsxImportPath = require.resolve('tsx', { paths: [__dirname] }); } catch {}
|
|
14
|
+
try { tsxCliPath = require.resolve('tsx/cli', { paths: [__dirname] }); } catch {}
|
|
13
15
|
|
|
14
16
|
// Enforce minimum Node version based on package.json engines.node
|
|
15
17
|
try {
|
|
@@ -56,7 +58,20 @@ function runWithTsxImport() {
|
|
|
56
58
|
const baseArgs = ['--no-warnings=ExperimentalWarning', '--enable-source-maps']
|
|
57
59
|
const child = spawn(process.execPath, [...baseArgs, '--import', importArg, cliPath, ...args], {
|
|
58
60
|
stdio: 'inherit',
|
|
59
|
-
env: { ...process.env, YOGA_WASM_PATH: path.join(__dirname, 'yoga.wasm')
|
|
61
|
+
env: { ...process.env, YOGA_WASM_PATH: path.join(__dirname, 'yoga.wasm') },
|
|
62
|
+
})
|
|
63
|
+
child.on('error', () => runWithTsxCLI())
|
|
64
|
+
child.on('exit', code => {
|
|
65
|
+
if (code && code !== 0) return runWithTsxCLI()
|
|
66
|
+
process.exit(code || 0)
|
|
67
|
+
})
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function runWithTsxCLI() {
|
|
71
|
+
if (!tsxCliPath) return fail()
|
|
72
|
+
const child = spawn(process.execPath, [tsxCliPath, cliPath, ...args], {
|
|
73
|
+
stdio: 'inherit',
|
|
74
|
+
env: { ...process.env, YOGA_WASM_PATH: path.join(__dirname, 'yoga.wasm') },
|
|
60
75
|
})
|
|
61
76
|
child.on('error', () => fail())
|
|
62
77
|
child.on('exit', code => process.exit(code || 0))
|