Skip to content

Commit

Permalink
fix: Fix unlock-packages script to remove packages in both package lo… (
Browse files Browse the repository at this point in the history
  • Loading branch information
taheramr authored Aug 2, 2023
1 parent f3fca14 commit 6c318a0
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions scripts/unlock-packages.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,22 @@ const fs = require('fs');
require.resolve('../packages/core/package-lock.json'),
].forEach(filename => unlock(filename));

function removeDependencies(dependencyName, packages) {
if (dependencyName.includes('@cloudscape-design/')) {
delete packages[dependencyName];
}
}

function unlock(filename) {
const packageLock = require(filename);
Object.keys(packageLock.packages).forEach(dependencyName => {
if (dependencyName.startsWith('node_modules/@cloudscape-design/')) {
delete packageLock.dependencies[dependencyName];
}
removeDependencies(dependencyName, packageLock.packages);
});

Object.keys(packageLock.dependencies).forEach(dependencyName => {
removeDependencies(dependencyName, packageLock.dependencies);
});

fs.writeFileSync(filename, JSON.stringify(packageLock, null, 2) + '\n');
console.log(`Removed @cloudscape-design/ dependencies from ${filename} file`);
}

0 comments on commit 6c318a0

Please sign in to comment.