From 098bc935e3f20f568338535d55c59e0a5a96a2f1 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Mon, 27 Sep 2021 23:12:55 +0300 Subject: [PATCH] test: add additional test for running scripts without `--` Cherry picked by Brandon Cheng from feat/3778 branch. --- packages/pnpm/test/run.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) 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({