Files
.github
.storybook
scripts
build
shared
tools
removeNodeModules.ts
build-storybook.ts
dump-keycloak-realm.ts
generate-i18n-messages.ts
link-in-app.ts
link-in-starter.ts
start-storybook.ts
src
stories
test
.all-contributorsrc
.gitattributes
.gitignore
.prettierignore
.prettierrc.json
CONTRIBUTING.md
LICENSE
README.md
package.json
renovate.json
tsproject.json
vitest.config.ts
yarn.lock
keycloak_theme/scripts/tools/removeNodeModules.ts

28 lines
785 B
TypeScript
Raw Normal View History

2024-10-24 23:21:12 +00:00
import * as fs from "fs";
import { crawl } from "../../src/bin/tools/crawl";
export function removeNodeModules(params: { nodeModulesDirPath: string }) {
const { nodeModulesDirPath } = params;
try {
fs.rmSync(nodeModulesDirPath, { recursive: true, force: true });
} catch {
// NOTE: This is a workaround for windows
// we can't remove locked executables.
crawl({
dirPath: nodeModulesDirPath,
returnedPathsType: "absolute"
}).forEach(filePath => {
try {
fs.rmSync(filePath, { force: true });
} catch (error) {
if (filePath.endsWith(".exe")) {
return;
}
throw error;
}
});
}
}