Skip to content

Commit

Permalink
fix: broken shebang parameters of cli-ts-node-commonjs and `cli-ts-…
Browse files Browse the repository at this point in the history
…node-esm` on some linux distros (#8821)

Changed to nodejs workaround instead of relying on shebang parameters, as they work a bit differently on some linux distros, and using the "-S" parameter breaks the CLI on Windows

Closes #8818
  • Loading branch information
giladgd committed Mar 29, 2022
1 parent 5ae9f37 commit c5dfc11
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/cli-ts-node-commonjs.ts
@@ -1,2 +1,3 @@
#!/usr/bin/env node --require ts-node/register
#!/usr/bin/env node
require("ts-node").register()
import "./cli"
22 changes: 20 additions & 2 deletions src/cli-ts-node-esm.ts
@@ -1,2 +1,20 @@
#!/usr/bin/env node --loader ts-node/esm --no-warnings
import "./cli"
#!/usr/bin/env node
import { spawnSync } from "child_process"

if ((process.env["NODE_OPTIONS"] || "").includes("--loader ts-node"))
require("./cli")
else
spawnSync(process.argv[0], process.argv.slice(1), {
stdio: "inherit",
env: {
...process.env,
NODE_OPTIONS: [
process.env["NODE_OPTIONS"],
"--loader ts-node/esm",
"--no-warnings",
]
.filter((item) => !!item)
.join(" "),
},
windowsHide: true,
})

0 comments on commit c5dfc11

Please sign in to comment.