fix: replace rm system calls with nodejs native functions; closes #219
This commit is contained in:
parent
2bfbba4daf
commit
e3200899e2
@ -4,7 +4,7 @@ import { join as pathJoin, relative as pathRelative, dirname as pathDirname } fr
|
|||||||
import { crawl } from "./tools/crawl";
|
import { crawl } from "./tools/crawl";
|
||||||
import { downloadBuiltinKeycloakTheme } from "./download-builtin-keycloak-theme";
|
import { downloadBuiltinKeycloakTheme } from "./download-builtin-keycloak-theme";
|
||||||
import { getProjectRoot } from "./tools/getProjectRoot";
|
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,
|
//NOTE: To run without argument when we want to generate src/i18n/generated_kcMessages files,
|
||||||
// update the version array for generating for newer version.
|
// 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");
|
const tmpDirPath = pathJoin(getProjectRoot(), "tmp_xImOef9dOd44");
|
||||||
|
|
||||||
rm_rf(tmpDirPath);
|
rmSync(tmpDirPath, {recursive: true, force: true});
|
||||||
|
|
||||||
downloadBuiltinKeycloakTheme({
|
downloadBuiltinKeycloakTheme({
|
||||||
keycloakVersion,
|
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 => {
|
Object.keys(record).forEach(pageType => {
|
||||||
const recordForPageType = record[pageType];
|
const recordForPageType = record[pageType];
|
||||||
|
@ -43,7 +43,8 @@ const commonThirdPartyDeps = (() => {
|
|||||||
|
|
||||||
const yarnHomeDirPath = pathJoin(keycloakifyDirPath, ".yarn_home");
|
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 execYarnLink = (params: { targetModuleName?: string; cwd: string }) => {
|
||||||
const { targetModuleName, cwd } = params;
|
const { targetModuleName, cwd } = params;
|
||||||
|
@ -2,7 +2,6 @@ import { basename as pathBasename, join as pathJoin } from "path";
|
|||||||
import { execSync } from "child_process";
|
import { execSync } from "child_process";
|
||||||
import * as fs from "fs";
|
import * as fs from "fs";
|
||||||
import { transformCodebase } from "./transformCodebase";
|
import { transformCodebase } from "./transformCodebase";
|
||||||
import { rm, rm_rf } from "./rm";
|
|
||||||
import * as crypto from "crypto";
|
import * as crypto from "crypto";
|
||||||
|
|
||||||
/** assert url ends with .zip */
|
/** assert url ends with .zip */
|
||||||
@ -48,7 +47,7 @@ export function downloadAndUnzip(params: { url: string; destDirPath: string; pat
|
|||||||
[extractDirPath]: false
|
[extractDirPath]: false
|
||||||
});
|
});
|
||||||
|
|
||||||
rm_rf(extractDirPath);
|
fs.rmSync(extractDirPath, {recursive: true, force: true});
|
||||||
|
|
||||||
fs.mkdirSync(extractDirPath);
|
fs.mkdirSync(extractDirPath);
|
||||||
|
|
||||||
@ -60,7 +59,7 @@ export function downloadAndUnzip(params: { url: string; destDirPath: string; pat
|
|||||||
"cwd": extractDirPath
|
"cwd": extractDirPath
|
||||||
});
|
});
|
||||||
|
|
||||||
rm(zipFileBasename, { "cwd": extractDirPath });
|
fs.rmSync(pathJoin(extractDirPath, zipFileBasename), {recursive: true, force: true});
|
||||||
|
|
||||||
writeIsSuccessByExtractDirPath({
|
writeIsSuccessByExtractDirPath({
|
||||||
...isSuccessByExtractDirPath,
|
...isSuccessByExtractDirPath,
|
||||||
|
@ -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
|
|
||||||
});
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user