|
1 | | -import { execFileSync, spawnSync } from 'node:child_process' |
| 1 | +import { execFileSync } from 'node:child_process' |
2 | 2 | import fs from 'node:fs' |
3 | 3 | import path from 'node:path' |
4 | 4 | import { extract } from 'tar' |
5 | 5 |
|
| 6 | +const npmExecPath = process.env.npm_execpath |
| 7 | +const npmBin = process.platform === 'win32' ? 'npm.cmd' : 'npm' |
6 | 8 | const PACKAGE_SPEC = |
7 | | - process.env.WASM_BINDING_PACKAGE ?? '@oxc-parser/binding-wasm32-wasi@^0.99.0' |
| 9 | + process.env.WASM_BINDING_PACKAGE ?? '@oxc-parser/binding-wasm32-wasi@^0.105.0' |
8 | 10 | const cwd = process.cwd() |
9 | | -const cliEntry = path.resolve(cwd, 'dist', 'cli', 'init.js') |
10 | | - |
11 | | -if (fs.existsSync(cliEntry)) { |
12 | | - const result = spawnSync(process.execPath, [cliEntry, '--skip-config', '--force'], { |
13 | | - cwd, |
14 | | - stdio: 'inherit', |
15 | | - }) |
16 | | - |
17 | | - process.exit(result.status ?? 0) |
18 | | -} |
19 | 11 |
|
20 | 12 | function runNpmPack() { |
21 | | - const output = execFileSync('npm', ['pack', PACKAGE_SPEC], { |
| 13 | + const baseOptions = { |
22 | 14 | cwd, |
23 | 15 | encoding: 'utf8', |
24 | 16 | stdio: ['ignore', 'pipe', 'inherit'], |
25 | | - }).trim() |
| 17 | + } |
| 18 | + const output = ( |
| 19 | + npmExecPath |
| 20 | + ? execFileSync(process.execPath, [npmExecPath, 'pack', PACKAGE_SPEC], baseOptions) |
| 21 | + : execFileSync(npmBin, ['pack', PACKAGE_SPEC], { |
| 22 | + ...baseOptions, |
| 23 | + shell: process.platform === 'win32', |
| 24 | + }) |
| 25 | + ).trim() |
26 | 26 | const lines = output.split('\n').filter(Boolean) |
27 | 27 |
|
28 | 28 | return lines[lines.length - 1] |
|
0 commit comments