diff --git a/packages/pnpm/src/cmd/recursive/run.ts b/packages/pnpm/src/cmd/recursive/run.ts index 1359dd475e..bcd0c036bd 100644 --- a/packages/pnpm/src/cmd/recursive/run.ts +++ b/packages/pnpm/src/cmd/recursive/run.ts @@ -33,6 +33,7 @@ export default async ( opts.workspaceConcurrency === 1 || packageChunks.length === 1 && packageChunks[0].length === 1 ) ? 'inherit' : 'pipe' + const passedThruArgs = args.slice(1) for (const chunk of packageChunks) { await Promise.all(chunk.map((prefix: string) => @@ -44,6 +45,7 @@ export default async ( hasCommand++ try { const lifecycleOpts = { + args: passedThruArgs, depPath: prefix, extraBinPaths: opts.extraBinPaths, pkgRoot: prefix, diff --git a/packages/pnpm/test/run.ts b/packages/pnpm/test/run.ts index c61bf3dfd8..13bc7742ed 100644 --- a/packages/pnpm/test/run.ts +++ b/packages/pnpm/test/run.ts @@ -1,4 +1,4 @@ -import prepare from '@pnpm/prepare' +import prepare, { preparePackages } from '@pnpm/prepare' import { stripIndent } from 'common-tags' import fs = require('mz/fs') import path = require('path') @@ -33,6 +33,19 @@ test('run: pass the args to the command that is specfied in the build script', a t.ok((result.stdout as Buffer).toString('utf8').match(/ts-node test "arg" "--flag=true"/), 'command was successful') }) +test('run -r: pass the args to the command that is specfied in the build script', async (t: tape.Test) => { + preparePackages(t, [{ + name: 'project', + scripts: { + foo: 'ts-node test' + }, + }]) + + const result = execPnpmSync('run', '-r', 'foo', 'arg', '--', '--flag=true') + + t.ok((result.stdout as Buffer).toString('utf8').match(/ts-node test "arg" "--flag=true"/), 'command was successful') +}) + test('run: pass the args to the command that is specfied in the build script of a package.yaml manifest', async (t: tape.Test) => { prepare(t, { scripts: { @@ -57,6 +70,19 @@ test('test: pass the args to the command that is specfied in the build script of t.ok((result.stdout as Buffer).toString('utf8').match(/ts-node test "--flag=true"/), 'command was successful') }) +test('test -r: pass the args to the command that is specfied in the build script of a package.json manifest', async (t: tape.Test) => { + preparePackages(t, [{ + name: 'project', + scripts: { + test: 'ts-node test' + }, + }]) + + const result = execPnpmSync('test', '-r', 'arg', '--', '--flag=true') + + t.ok((result.stdout as Buffer).toString('utf8').match(/ts-node test "arg" "--flag=true"/), 'command was successful') +}) + test('start: pass the args to the command that is specfied in the build script of a package.yaml manifest', async (t: tape.Test) => { prepare(t, { scripts: {