Skip to content

Commit 70a61ff

Browse files
committed
fix: remove node_modules & package-lock.json for all packages if no scope is provided
1 parent 8f315eb commit 70a61ff

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

bin/rebuild-package-locks.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,13 @@ async function removePackageLocks(project, ...scopes) {
2525
const packages = await project.getPackages();
2626
const rootPath = project.rootPath;
2727
const pkgRoots = [];
28-
const matchedPackages = filterPackages(packages, scopes, [], true, true);
29-
if (matchedPackages.length === 0) {
30-
console.error('No matching packages found for %s', scopes);
31-
return pkgRoots;
28+
let matchedPackages = packages;
29+
if (scopes.length) {
30+
matchedPackages = filterPackages(packages, scopes, [], true, true);
31+
if (matchedPackages.length === 0) {
32+
console.error('No matching packages found for %s', scopes);
33+
return pkgRoots;
34+
}
3235
}
3336
for (const pkg of matchedPackages) {
3437
pkgRoots.push(pkg.location);
@@ -71,6 +74,7 @@ async function rebuildPackageLocks(...scopes) {
7174
cwd: project.rootPth,
7275
});
7376
} else {
77+
await removePackageLocks(project, ...scopes);
7478
console.log('Running npm install...');
7579
build.runShell('npm', ['install'], {cwd: project.rootPth});
7680
}

0 commit comments

Comments
 (0)