refactor: move recursive list to separate file

This commit is contained in:
Zoltan Kochan
2018-05-23 09:31:17 +03:00
parent 7e625b9549
commit 22d4dfa97b
2 changed files with 25 additions and 8 deletions

View File

@@ -19,7 +19,7 @@ import createStoreController from '../../createStoreController'
import getCommandFullName from '../../getCommandFullName'
import requireHooks from '../../requireHooks'
import {PnpmOptions} from '../../types'
import list from '../list'
import list from './list'
const supportedRecursiveCommands = new Set([
'install',
@@ -52,10 +52,6 @@ export default async (
}
logger.warn('The recursive command is an experimental feature. Breaking changes may happen in non-major versions.')
if (cmdFullName === 'update') {
opts = {...opts, update: true}
}
const cwd = process.cwd()
const packagesManifest = await requirePackagesManifest(cwd)
const pkgs = await findPackages(cwd, {
@@ -66,11 +62,12 @@ export default async (
patterns: packagesManifest && packagesManifest.packages || undefined,
})
if (cmdFullName === 'list') {
for (const pkg of pkgs) {
await list(input, {...opts, prefix: pkg.path, alwaysPrintRootPackage: false} as any, cmd) // tslint:disable-line:no-any
}
await list(pkgs, input, cmd, opts as any) // tslint:disable-line:no-any
return
}
if (cmdFullName === 'update') {
opts = {...opts, update: true}
}
const pkgGraphResult = createPkgGraph(pkgs)
const store = await createStoreController(opts)

View File

@@ -0,0 +1,20 @@
import {PackageJson} from '@pnpm/types'
import list from '../list'
export default async (
pkgs: Array<{path: string, manifest: PackageJson}>,
args: string[],
cmd: string,
opts: {
depth?: number,
only?: 'dev' | 'prod',
long?: boolean,
parseable?: boolean,
global: boolean,
independentLeaves: boolean,
},
) => {
for (const pkg of pkgs) {
await list(args, {...opts, prefix: pkg.path, alwaysPrintRootPackage: false}, cmd)
}
}