Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions lib/base-cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,19 @@ class BaseCommand {
this.workspaceNames = [...ws.keys()]
this.workspacePaths = [...ws.values()]
}

/** commands like ci use workspace config but not --workspace */
async setWorkspaceFlagIndependent () {
this.workspace = new Map()
this.workspaceNames = []
this.workspacePaths = []

try {
await this.setWorkspaces({ forgiveFlagError: true })
} catch {
// noop
}
}
}

module.exports = BaseCommand
15 changes: 10 additions & 5 deletions lib/commands/ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class CI extends ArboristWorkspaceCmd {
})
}

await this.setWorkspaceFlagIndependent()

const where = this.npm.prefix
const Arborist = require('@npmcli/arborist')
const opts = {
Expand Down Expand Up @@ -79,11 +81,14 @@ class CI extends ArboristWorkspaceCmd {
// Only remove node_modules after we've successfully loaded the virtual
// tree and validated the lockfile
await time.start('npm-ci:rm', async () => {
const path = `${where}/node_modules`
// get the list of entries so we can skip the glob for performance
const entries = await fs.readdir(path, null).catch(() => [])
return Promise.all(entries.map(f => fs.rm(`${path}/${f}`,
{ force: true, recursive: true })))
return await Promise.all([where, ...this.workspacePaths].map(async modulePath => {
const path = `${modulePath}/node_modules`
// get the list of entries so we can skip the glob for performance
const entries = await fs.readdir(path, null).catch(() => [])
return Promise.all(entries.map(f => {
return fs.rm(`${path}/${f}`, { force: true, recursive: true })
}))
}))
})
}

Expand Down