perf: don't unnecessarily search for projects

This commit is contained in:
Zoltan Kochan
2020-01-02 04:37:30 +02:00
parent a8a5f58e00
commit 68a8d31cc7

View File

@@ -330,12 +330,13 @@ export async function handler (
input = input.filter(Boolean)
const dir = opts.dir || process.cwd()
let allProjects = opts.allProjects
let workspacePackages = undefined
const workspacePackages = opts.workspaceDir
? arrayOfWorkspacePackagesToMap(
await findWorkspacePackages(opts.workspaceDir, opts),
)
: undefined
if (opts.workspaceDir) {
allProjects = allProjects ?? await findWorkspacePackages(opts.workspaceDir, opts)
workspacePackages = arrayOfWorkspacePackagesToMap(allProjects)
}
const store = await createOrConnectStoreController(opts)
const installOpts = {
@@ -404,9 +405,7 @@ export async function handler (
}
if (opts.linkWorkspacePackages && opts.workspaceDir) {
// TODO: reuse somehow the previous read of packages
// this is not optimal
const allProjects = await findWorkspacePackages(opts.workspaceDir, opts)
allProjects = allProjects ?? await findWorkspacePackages(opts.workspaceDir, opts)
const selectedProjectsGraph = await filterPkgsBySelectorObjects(allProjects, [
{
excludeSelf: true,