feat: have if-present apply to recursive runs

PR #2520
This commit is contained in:
Jonathan Morley authored and GitHub committed 2020-05-01 23:39:41 +03:00
1 parent 3919db0faf
commit 7300eba86e
4 files changed
+33 -5

No files matched your search

@@ -135,7 +135,7 @@ test('pnpm recursive run concurrently', async (t) => {
t.end()
})
test('`pnpm recursive run` fails when run without filters and no package has the desired command', async (t) => {
test('`pnpm recursive run` fails when run without filters and no package has the desired command, unless if-present is set', async (t) => {
const projects = preparePackages(t, [
{
name: 'project-1',
@@ -173,6 +173,17 @@ test('`pnpm recursive run` fails when run without filters and no package has the
path.resolve(DEFAULT_OPTS.storeDir),
])
t.comment('recursive run does not fail when if-present is true')
await run.handler({
...DEFAULT_OPTS,
allProjects,
dir: process.cwd(),
ifPresent: true,
recursive: true,
selectedProjectsGraph,
workspaceDir: process.cwd(),
}, ['this-command-does-not-exist'])
let err!: PnpmError
try {
await run.handler({
@@ -190,7 +201,7 @@ test('`pnpm recursive run` fails when run without filters and no package has the
t.end()
})
test('`pnpm recursive run` fails when run with a filter that includes all packages and no package has the desired command', async (t) => {
test('`pnpm recursive run` fails when run with a filter that includes all packages and no package has the desired command, unless if-present is set', async (t) => {
const projects = preparePackages(t, [
{
name: 'project-1',
@@ -218,6 +229,16 @@ test('`pnpm recursive run` fails when run with a filter that includes all packag
},
])
t.comment('recursive run does not fail when if-present is true')
await run.handler({
...DEFAULT_OPTS,
...await readProjects(process.cwd(), [{ namePattern: '*' }]),
dir: process.cwd(),
ifPresent: true,
recursive: true,
workspaceDir: process.cwd(),
}, ['this-command-does-not-exist'])
let err!: PnpmError
try {
await run.handler({