Skip to content
Merged
Changes from 3 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
21 changes: 16 additions & 5 deletions lib/commands/ci.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const fs = require('fs/promises')
const { log, time } = require('proc-log')
const validateLockfile = require('../utils/validate-lockfile.js')
const ArboristWorkspaceCmd = require('../arborist-cmd.js')
const getWorkspaces = require('../utils/get-workspaces.js')

class CI extends ArboristWorkspaceCmd {
static description = 'Clean install a project'
Expand Down Expand Up @@ -33,6 +34,13 @@ class CI extends ArboristWorkspaceCmd {
})
}

this.workspaces = await getWorkspaces([], {
path: this.npm.localPrefix,
includeWorkspaceRoot: true,
})
this.workspaceNames = [...this.workspaces.keys()]
this.workspacePaths = [...this.workspaces.values()]

const where = this.npm.prefix
const Arborist = require('@npmcli/arborist')
const opts = {
Expand Down Expand Up @@ -79,11 +87,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