diff --git a/packages/pnpm/test/run.ts b/packages/pnpm/test/run.ts index 868fb0fe8cf..3a26f4e5c4f 100644 --- a/packages/pnpm/test/run.ts +++ b/packages/pnpm/test/run.ts @@ -27,6 +27,26 @@ test('run -r: pass the args to the command that is specfied in the build script' ]) }) +test('run: pass the args to the command that is specfied in the build script', async () => { + prepare({ + name: 'project', + scripts: { + foo: 'node recordArgs', + postfoo: 'node recordArgs', + prefoo: 'node recordArgs', + }, + }) + await fs.writeFile('args.json', '[]', 'utf8') + await fs.writeFile('recordArgs.js', RECORD_ARGS_FILE, 'utf8') + + await execPnpm(['run', 'foo', 'arg', '--flag=true']) + + const { default: args } = await import(path.resolve('args.json')) + expect(args).toStrictEqual([ + ['arg', '--flag=true'], + ]) +}) + // Before pnpm v7, `--` was required to pass flags to a build script. test('run: handle -- in a backwards compatible manner', async () => { prepare({