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 14, 2020
1 parent d1ccc43 commit 6f6519d
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 21 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
8 changes: 5 additions & 3 deletions packages/plugin-commands-installation/src/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import R = require('ramda')
import renderHelp = require('render-help')
import installDeps from './installDeps'

export const rcOptionsTypes = cliOptionsTypes

export function cliOptionsTypes () {
return R.pick([
'child-concurrency',
Expand All @@ -39,7 +37,6 @@ export function cliOptionsTypes () {
'prefer-frozen-lockfile',
'prefer-offline',
'production',
'recursive',
'registry',
'reporter',
'resolution-strategy',
Expand All @@ -62,6 +59,11 @@ export function cliOptionsTypes () {
], allTypes)
}

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

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

export const rcOptionsTypes = cliOptionsTypes

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

export const rcOptionsTypes = () => ({
...cliOptionsTypes(),
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
8 changes: 5 additions & 3 deletions packages/plugin-commands-listing/src/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import R = require('ramda')
import renderHelp = require('render-help')
import listRecursive from './recursive'

export const rcOptionsTypes = cliOptionsTypes

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

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

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

export const rcOptionsTypes = cliOptionsTypes

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

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

export const commandNames = ['why']

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

export const rcOptionsTypes = cliOptionsTypes

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

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

export const shorthands = {
'D': '--dev',
'P': '--production',
Expand Down
1 change: 1 addition & 0 deletions packages/plugin-commands-rebuild/src/rebuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export function rcOptionsTypes () {
...R.pick([
'npm-path',
], allTypes),
recursive: Boolean,
}
}

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

export const commandNames = ['exec']

export const rcOptionsTypes = cliOptionsTypes

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

export const rcOptionsTypes = () => ({
...cliOptionsTypes(),
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 @@ -25,6 +25,7 @@ export function rcOptionsTypes () {
...R.pick([
'npm-path',
], allTypes),
recursive: Boolean,
}
}

Expand Down
1 change: 1 addition & 0 deletions packages/plugin-commands-script-runners/src/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export function rcOptionsTypes () {
...R.pick([
'npm-path',
], allTypes),
recursive: Boolean,
}
}

Expand Down

0 comments on commit 6f6519d

Please sign in to comment.