.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
28 lines
785 B
TypeScript
28 lines
785 B
TypeScript
![]() |
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;
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
}
|