Skip to content

Commit

Permalink
fix: pass argv to child_process (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
sirenkovladd authored Jan 7, 2024
1 parent 8e941b5 commit ac2e839
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/runtime/process-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default class ProcessWorker implements TinypoolWorker {
initialize(options: Parameters<TinypoolWorker['initialize']>[0]) {
this.process = fork(
fileURLToPath(import.meta.url + '/../entry/process.js'),
options.argv,
options
)
this.threadId = this.process.pid!
Expand Down
11 changes: 11 additions & 0 deletions test/simple.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,17 @@ test('passing argv to workers works', async () => {
expect(env).toEqual(['a', 'b', 'c'])
})

test('passing argv to child process', async () => {
const pool = new Tinypool({
runtime: 'child_process',
filename: resolve(__dirname, 'fixtures/eval.js'),
argv: ['a', 'b', 'c'],
})

const env = await pool.run('process.argv.slice(2)')
expect(env).toEqual(['a', 'b', 'c'])
})

test('passing execArgv to workers works', async () => {
const pool = new Tinypool({
filename: resolve(__dirname, 'fixtures/eval.js'),
Expand Down

0 comments on commit ac2e839

Please sign in to comment.