Skip to content

Commit

Permalink
fix: the -r option is not supported by all cmds
Browse files Browse the repository at this point in the history
ref #2396
  • Loading branch information
zkochan committed Mar 15, 2020
1 parent d1ccc43 commit 906ede3
Show file tree
Hide file tree
Showing 13 changed files with 63 additions and 46 deletions.
6 changes: 4 additions & 2 deletions packages/parse-cli-args/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ export default async function parseCliArgs (
const commandName = getCommandName(noptExploratoryResults.argv.remain)
let cmd = commandName ? opts.getCommandLongName(commandName) : null
const types = {
'recursive': Boolean,
...opts.universalOptionsTypes,
...opts.getTypesByCommandName(commandName),
} as any // tslint:disable-line:no-any
Expand All @@ -74,7 +73,10 @@ export default async function parseCliArgs (
}

const { argv, ...options } = nopt(
types,
{
'recursive': Boolean,
...types,
},
{
...opts.universalShorthands,
...opts.shorthandsByCommandName[commandName],
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-commands-installation/src/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export function rcOptionsTypes () {
'pnpmfile',
'prefer-offline',
'production',
'recursive',
'registry',
'reporter',
'resolution-strategy',
Expand Down Expand Up @@ -65,6 +64,7 @@ export function rcOptionsTypes () {
export function cliOptionsTypes () {
return {
...rcOptionsTypes(),
recursive: Boolean,
save: Boolean,
workspace: Boolean,
}
Expand Down
12 changes: 7 additions & 5 deletions packages/plugin-commands-installation/src/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,12 @@ import R = require('ramda')
import renderHelp = require('render-help')
import installDeps from './installDeps'

export const rcOptionsTypes = cliOptionsTypes

export function cliOptionsTypes () {
export function rcOptionsTypes () {
return R.pick([
'child-concurrency',
'dev',
'engine-strict',
'frozen-lockfile',
'force',
'global-dir',
'global-pnpmfile',
'global',
Expand All @@ -39,7 +36,6 @@ export function cliOptionsTypes () {
'prefer-frozen-lockfile',
'prefer-offline',
'production',
'recursive',
'registry',
'reporter',
'resolution-strategy',
Expand All @@ -62,6 +58,12 @@ export function cliOptionsTypes () {
], allTypes)
}

export const cliOptionsTypes = () => ({
...rcOptionsTypes(),
...R.pick(['force'], allTypes),
recursive: Boolean,
})

export const shorthands = {
'D': '--dev',
'P': '--production',
Expand Down
12 changes: 7 additions & 5 deletions packages/plugin-commands-installation/src/remove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,8 @@ import {
} from 'supi'
import recursive from './recursive'

export const rcOptionsTypes = cliOptionsTypes

export function cliOptionsTypes () {
export function rcOptionsTypes () {
return R.pick([
'force',
'global-dir',
'global-pnpmfile',
'global',
Expand All @@ -32,7 +29,6 @@ export function cliOptionsTypes () {
'lockfile',
'package-import-method',
'pnpmfile',
'recursive',
'reporter',
'resolution-strategy',
'save-dev',
Expand All @@ -45,6 +41,12 @@ export function cliOptionsTypes () {
], allTypes)
}

export const cliOptionsTypes = () => ({
...rcOptionsTypes(),
...R.pick(['force'], allTypes),
recursive: Boolean,
})

export function help () {
return renderHelp({
aliases: ['rm', 'r', 'uninstall', 'un'],
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-commands-installation/src/update/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export function rcOptionsTypes () {
'pnpmfile',
'prefer-offline',
'production',
'recursive',
'registry',
'reporter',
'resolution-strategy',
Expand All @@ -63,6 +62,7 @@ export function cliOptionsTypes () {
...rcOptionsTypes(),
interactive: Boolean,
latest: Boolean,
recursive: Boolean,
workspace: Boolean,
}
}
Expand Down
10 changes: 6 additions & 4 deletions packages/plugin-commands-listing/src/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import R = require('ramda')
import renderHelp = require('render-help')
import listRecursive from './recursive'

export const rcOptionsTypes = cliOptionsTypes

export function cliOptionsTypes () {
export function rcOptionsTypes () {
return R.pick([
'depth',
'dev',
Expand All @@ -22,10 +20,14 @@ export function cliOptionsTypes () {
'optional',
'parseable',
'production',
'recursive',
], allTypes)
}

export const cliOptionsTypes = () => ({
...rcOptionsTypes(),
recursive: Boolean,
})

export const shorthands = {
'D': '--dev',
'P': '--production',
Expand Down
10 changes: 6 additions & 4 deletions packages/plugin-commands-listing/src/why.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import R = require('ramda')
import renderHelp = require('render-help')
import { handler as list, ListCommandOptions } from './list'

export const rcOptionsTypes = cliOptionsTypes

export function cliOptionsTypes () {
export function rcOptionsTypes () {
return R.pick([
'dev',
'global-dir',
Expand All @@ -20,10 +18,14 @@ export function cliOptionsTypes () {
'optional',
'parseable',
'production',
'recursive',
], allTypes)
}

export const cliOptionsTypes = () => ({
...rcOptionsTypes(),
recursive: Boolean,
})

export const commandNames = ['why']

export function help () {
Expand Down
10 changes: 6 additions & 4 deletions packages/plugin-commands-outdated/src/outdated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ import {
OutdatedWithVersionDiff,
} from './utils'

export const rcOptionsTypes = cliOptionsTypes

export function cliOptionsTypes () {
export function rcOptionsTypes () {
return {
...R.pick([
'depth',
Expand All @@ -39,13 +37,17 @@ export function cliOptionsTypes () {
'long',
'optional',
'production',
'recursive',
], allTypes),
'compatible': Boolean,
'table': Boolean,
}
}

export const cliOptionsTypes = () => ({
...rcOptionsTypes(),
recursive: Boolean,
})

export const shorthands = {
'D': '--dev',
'P': '--production',
Expand Down
10 changes: 5 additions & 5 deletions packages/plugin-commands-rebuild/src/rebuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ export function rcOptionsTypes () {
return {
...R.pick([
'npm-path',
'reporter',
'unsafe-perm',
], allTypes),
}
}

export function cliOptionsTypes () {
return {
...R.pick([
'reporter',
'unsafe-perm',
], allTypes),
'pending': Boolean,
...rcOptionsTypes(),
pending: Boolean,
recursive: Boolean,
}
}

Expand Down
9 changes: 6 additions & 3 deletions packages/plugin-commands-script-runners/src/exec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import renderHelp = require('render-help')

export const commandNames = ['exec']

export const rcOptionsTypes = cliOptionsTypes

export function cliOptionsTypes () {
export function rcOptionsTypes () {
return R.pick([
'bail',
'sort',
Expand All @@ -20,6 +18,11 @@ export function cliOptionsTypes () {
], types)
}

export const cliOptionsTypes = () => ({
...rcOptionsTypes(),
recursive: Boolean,
})

export function help () {
return renderHelp({
description: 'Run a command in each package.',
Expand Down
1 change: 1 addition & 0 deletions packages/plugin-commands-script-runners/src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export function cliOptionsTypes () {
'workspace-concurrency',
], allTypes),
...IF_PRESENT_OPTION,
recursive: Boolean,
}
}

Expand Down
3 changes: 1 addition & 2 deletions packages/plugin-commands-script-runners/src/runRecursive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default async (
params: string[],
opts: RecursiveRunOpts,
) => {
const scriptName = params[0]
const [scriptName, ...passedThruArgs] = params
let hasCommand = 0
const packageChunks = opts.sort
? sortPackages(opts.selectedProjectsGraph)
Expand All @@ -34,7 +34,6 @@ export default async (
opts.workspaceConcurrency === 1 ||
packageChunks.length === 1 && packageChunks[0].length === 1
) ? 'inherit' : 'pipe'
const passedThruArgs = params.slice(1)

for (const chunk of packageChunks) {
await Promise.all(chunk.map((prefix: string) =>
Expand Down
22 changes: 12 additions & 10 deletions packages/plugin-commands-script-runners/src/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,24 @@ import renderHelp = require('render-help')
import { handler as run, RunOpts } from './run'

export function rcOptionsTypes () {
return {
...R.pick([
'npm-path',
], allTypes),
}
}

export function cliOptionsTypes () {
return R.pick([
'bail',
'sort',
'npm-path',
'unsafe-perm',
'workspace-concurrency',
], allTypes)
}

export function cliOptionsTypes () {
return {
...rcOptionsTypes(),
...R.pick([
'bail',
'sort',
], allTypes),
recursive: Boolean,
}
}

export const commandNames = ['test', 't', 'tst']

export function help () {
Expand Down

0 comments on commit 906ede3

Please sign in to comment.