diff --git a/src/bin/generate-i18n-messages.ts b/src/bin/generate-i18n-messages.ts index 431efe7d..8ceabbf6 100644 --- a/src/bin/generate-i18n-messages.ts +++ b/src/bin/generate-i18n-messages.ts @@ -4,7 +4,7 @@ import { join as pathJoin, relative as pathRelative, dirname as pathDirname } fr import { crawl } from "./tools/crawl"; import { downloadBuiltinKeycloakTheme } from "./download-builtin-keycloak-theme"; import { getProjectRoot } from "./tools/getProjectRoot"; -import { rm_rf, rm_r } from "./tools/rm"; +import { rmSync } from "fs"; //NOTE: To run without argument when we want to generate src/i18n/generated_kcMessages files, // update the version array for generating for newer version. @@ -17,7 +17,7 @@ for (const keycloakVersion of ["11.0.3", "15.0.2", "18.0.1"]) { const tmpDirPath = pathJoin(getProjectRoot(), "tmp_xImOef9dOd44"); - rm_rf(tmpDirPath); + rmSync(tmpDirPath, {recursive: true, force: true}); downloadBuiltinKeycloakTheme({ keycloakVersion, @@ -48,7 +48,7 @@ for (const keycloakVersion of ["11.0.3", "15.0.2", "18.0.1"]) { }); } - rm_r(tmpDirPath); + rmSync(tmpDirPath, {recursive: true, force: true}); Object.keys(record).forEach(pageType => { const recordForPageType = record[pageType]; diff --git a/src/bin/link_in_test_app.ts b/src/bin/link_in_test_app.ts index b482c1f1..4d4703bd 100644 --- a/src/bin/link_in_test_app.ts +++ b/src/bin/link_in_test_app.ts @@ -43,7 +43,8 @@ const commonThirdPartyDeps = (() => { const yarnHomeDirPath = pathJoin(keycloakifyDirPath, ".yarn_home"); -execSync(["rm -rf", "mkdir"].map(cmd => `${cmd} ${yarnHomeDirPath}`).join(" && ")); +fs.rmSync(yarnHomeDirPath, {recursive: true, force: true}); +fs.mkdirSync(yarnHomeDirPath); const execYarnLink = (params: { targetModuleName?: string; cwd: string }) => { const { targetModuleName, cwd } = params; diff --git a/src/bin/tools/downloadAndUnzip.ts b/src/bin/tools/downloadAndUnzip.ts index 1522e327..d3aa0e67 100644 --- a/src/bin/tools/downloadAndUnzip.ts +++ b/src/bin/tools/downloadAndUnzip.ts @@ -2,7 +2,6 @@ import { basename as pathBasename, join as pathJoin } from "path"; import { execSync } from "child_process"; import * as fs from "fs"; import { transformCodebase } from "./transformCodebase"; -import { rm, rm_rf } from "./rm"; import * as crypto from "crypto"; /** assert url ends with .zip */ @@ -48,7 +47,7 @@ export function downloadAndUnzip(params: { url: string; destDirPath: string; pat [extractDirPath]: false }); - rm_rf(extractDirPath); + fs.rmSync(extractDirPath, {recursive: true, force: true}); fs.mkdirSync(extractDirPath); @@ -60,7 +59,7 @@ export function downloadAndUnzip(params: { url: string; destDirPath: string; pat "cwd": extractDirPath }); - rm(zipFileBasename, { "cwd": extractDirPath }); + fs.rmSync(pathJoin(extractDirPath, zipFileBasename), {recursive: true, force: true}); writeIsSuccessByExtractDirPath({ ...isSuccessByExtractDirPath, diff --git a/src/bin/tools/rm.ts b/src/bin/tools/rm.ts deleted file mode 100644 index d429e391..00000000 --- a/src/bin/tools/rm.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { execSync } from "child_process"; - -function rmInternal(params: { pathToRemove: string; args: string | undefined; cwd: string | undefined }) { - const { pathToRemove, args, cwd } = params; - - execSync(`rm ${args ? `-${args} ` : ""}${pathToRemove.replace(/ /g, "\\ ")}`, cwd !== undefined ? { cwd } : undefined); -} - -export function rm(pathToRemove: string, options?: { cwd: string }) { - rmInternal({ - pathToRemove, - "args": undefined, - "cwd": options?.cwd - }); -} - -export function rm_r(pathToRemove: string, options?: { cwd: string }) { - rmInternal({ - pathToRemove, - "args": "r", - "cwd": options?.cwd - }); -} - -export function rm_rf(pathToRemove: string, options?: { cwd: string }) { - rmInternal({ - pathToRemove, - "args": "rf", - "cwd": options?.cwd - }); -}