fix: replace rm system calls with nodejs native functions; closes #219

This commit is contained in:
Waldemar Reusch 2023-01-08 12:19:41 +01:00 committed by GitHub
parent 2bfbba4daf
commit e3200899e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 38 deletions

View File

@ -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];

View File

@ -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;

View File

@ -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,

View File

@ -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
});
}