Skip to content

Commit

Permalink
test: add additional test for running scripts without --
Browse files Browse the repository at this point in the history
Cherry picked by Brandon Cheng from feat/3778 branch.
  • Loading branch information
zkochan authored and gluxon committed Jan 30, 2022
1 parent a4604be commit 098bc93
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/pnpm/test/run.ts
Expand Up @@ -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({
Expand Down

0 comments on commit 098bc93

Please sign in to comment.