node v2 cli support (#36309)
This commit is contained in:
parent
27e1692848
commit
a1b274e6f8
75 changed files with 1502 additions and 367 deletions
5
packages/cli/src/util/io.ts
Normal file
5
packages/cli/src/util/io.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import { text } from "node:stream/consumers"
|
||||
|
||||
export function readStdin() {
|
||||
return text(process.stdin)
|
||||
}
|
||||
26
packages/cli/src/util/process.ts
Normal file
26
packages/cli/src/util/process.ts
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import path from "node:path"
|
||||
|
||||
export function selfCommand() {
|
||||
const runtime = path.basename(process.execPath, path.extname(process.execPath)).toLowerCase()
|
||||
if (runtime !== "bun" && runtime !== "node" && runtime !== "nodejs") return [process.execPath]
|
||||
if (!process.argv[1]) throw new Error("Failed to resolve CLI entrypoint")
|
||||
if (runtime === "node" || runtime === "nodejs") return [process.execPath, ...nodeFlags(), process.argv[1]]
|
||||
return [process.execPath, process.argv[1]]
|
||||
}
|
||||
|
||||
function nodeFlags() {
|
||||
return process.execArgv.flatMap((arg, index, args) => {
|
||||
if (index > 0 && args[index - 1] === "--conditions") return []
|
||||
if (arg === "--conditions") return args[index + 1] ? [arg, args[index + 1]] : []
|
||||
if (arg.startsWith("--conditions=")) return [arg]
|
||||
if (
|
||||
arg === "--experimental-ffi" ||
|
||||
arg === "--use-system-ca" ||
|
||||
arg === "--enable-source-maps" ||
|
||||
arg === "--no-addons"
|
||||
)
|
||||
return [arg]
|
||||
if (arg === "--no-warnings" || arg.startsWith("--disable-warning=")) return [arg]
|
||||
return []
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue