diff --git a/src/runtime/process-worker.ts b/src/runtime/process-worker.ts index 8830c23..5139718 100644 --- a/src/runtime/process-worker.ts +++ b/src/runtime/process-worker.ts @@ -22,6 +22,7 @@ export default class ProcessWorker implements TinypoolWorker { initialize(options: Parameters[0]) { this.process = fork( fileURLToPath(import.meta.url + '/../entry/process.js'), + options.argv, options ) this.threadId = this.process.pid! diff --git a/test/simple.test.ts b/test/simple.test.ts index 7741da7..85e5c99 100644 --- a/test/simple.test.ts +++ b/test/simple.test.ts @@ -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'),