Files
nexe/src/steps/shim.ts
T
2017-09-09 02:02:52 -05:00

19 lines
460 B
TypeScript

import { NexeCompiler } from '../compiler'
export default function(compiler: NexeCompiler, next: () => Promise<void>) {
if (!compiler.options.fakeArgv) {
return next()
}
const nty = !process.stdin.isTTY
const input = nty ? '[stdin]' : compiler.options.input
compiler.input =
`!(() => {
var r = require('path').resolve;
process.argv.splice(1,0, ${nty ? `'${input}'` : `r("${input}")`});
})();` + compiler.input
return next()
}