-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresetdeps.js
27 lines (23 loc) · 1 KB
/
resetdeps.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const { join } = require('node:path')
const { symlink } = require('node:fs/promises')
const { CWD, run, pkg, fs, git, npm } = require('./util.js')
const cleanup = async () => {
await git('checkout', 'node_modules/')
for (const { name, path } of await pkg.mapWorkspaces({ public: true })) {
// add symlinks similar to how arborist does for our production
// workspaces, so they are in place before the initial install.
await symlink(path, join(CWD, 'node_modules', name), 'junction')
}
}
const main = async ({ packageLock }) => {
await git('status') // run ANY @npmcli/git command to instantiate its lazy loading
await fs.rimraf(join(CWD, 'node_modules'))
for (const { path } of await pkg.mapWorkspaces()) {
await fs.rimraf(join(path, 'node_modules'))
}
await cleanup()
await npm('i', '--ignore-scripts', '--no-audit', '--no-fund', packageLock && '--package-lock')
await npm('rebuild', '--ignore-scripts')
await npm('run', 'dependencies', '--ignore-scripts')
}
run(main).catch(cleanup)