fix(CLI): recursive run should pass thru arguments to the cmds

PR #1952
This commit is contained in:
Zoltan Kochan
2019-08-09 02:16:53 +03:00
committed by GitHub
parent 1881446a4f
commit ed0bb92b93
2 changed files with 29 additions and 1 deletions

View File

@@ -33,6 +33,7 @@ export default async <T> (
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 <T> (
hasCommand++
try {
const lifecycleOpts = {
args: passedThruArgs,
depPath: prefix,
extraBinPaths: opts.extraBinPaths,
pkgRoot: prefix,

View File

@@ -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: {