Skip to content

Commit

Permalink
patch fd
Browse files Browse the repository at this point in the history
  • Loading branch information
David Mark Clements committed Mar 21, 2019
1 parent 9242190 commit 3a10bf0
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/transport.js
Expand Up @@ -2,10 +2,15 @@

const { Worker } = require('worker_threads')

function transport (name, args = []) {
const filename = require.resolve(name)
const worker = new Worker(filename, {
execArgv: args,
function transport (filePath, args = []) {
args.unshift(filePath)
const code = `
process.stdin.fd = 1
process.argv.push(...${JSON.stringify(args)})
require('${filePath}')
`
const worker = new Worker(code, {
eval: true,
stdin: true
})
return worker.stdin
Expand Down

0 comments on commit 3a10bf0

Please sign in to comment.