From f55d61bf0bb773b8e1048269b8824b3d5efac2cf Mon Sep 17 00:00:00 2001 From: Joseph Garrone Date: Tue, 30 Jan 2024 00:10:59 +0100 Subject: [PATCH] Rename test case file --- .../replacers/replaceImportsInJsCode/webpack.ts | 10 +++++++--- ...placeImportFromStatic.spec.ts => replacers.spec.ts} | 8 ++++---- 2 files changed, 11 insertions(+), 7 deletions(-) rename test/bin/{replaceImportFromStatic.spec.ts => replacers.spec.ts} (99%) diff --git a/src/bin/keycloakify/replacers/replaceImportsInJsCode/webpack.ts b/src/bin/keycloakify/replacers/replaceImportsInJsCode/webpack.ts index 5648cab7..5a7d91dd 100644 --- a/src/bin/keycloakify/replacers/replaceImportsInJsCode/webpack.ts +++ b/src/bin/keycloakify/replacers/replaceImportsInJsCode/webpack.ts @@ -1,7 +1,7 @@ import { nameOfTheGlobal, basenameOfTheKeycloakifyResourcesDir } from "../../../constants"; import { assert } from "tsafe/assert"; import type { BuildOptions } from "../../BuildOptions"; -import { relative as pathRelative, sep as pathSep } from "path"; +import * as nodePath from "path"; import { replaceAll } from "../../../tools/String.prototype.replaceAll"; export type BuildOptionsLike = { @@ -12,8 +12,12 @@ export type BuildOptionsLike = { assert(); -export function replaceImportsInJsCode_webpack(params: { jsCode: string; buildOptions: BuildOptionsLike }): { fixedJsCode: string } { - const { jsCode, buildOptions } = params; +export function replaceImportsInJsCode_webpack(params: { jsCode: string; buildOptions: BuildOptionsLike; systemType?: "posix" | "win32" }): { + fixedJsCode: string; +} { + const { jsCode, buildOptions, systemType = nodePath.sep === "/" ? "posix" : "win32" } = params; + + const { relative: pathRelative, sep: pathSep } = nodePath[systemType]; let fixedJsCode = jsCode; diff --git a/test/bin/replaceImportFromStatic.spec.ts b/test/bin/replacers.spec.ts similarity index 99% rename from test/bin/replaceImportFromStatic.spec.ts rename to test/bin/replacers.spec.ts index bfe9cc22..4c5771c3 100644 --- a/test/bin/replaceImportFromStatic.spec.ts +++ b/test/bin/replacers.spec.ts @@ -6,7 +6,7 @@ import { expect, it, describe } from "vitest"; import { isSameCode } from "../tools/isSameCode"; import { basenameOfTheKeycloakifyResourcesDir, nameOfTheGlobal } from "keycloakify/bin/constants"; -describe("bin/js-transforms - vite", () => { +describe("js replacer - vite", () => { it("replaceImportsInJsCode_vite - 1", () => { const before = `Uv="modulepreload",`; const after = `,Wc={},`; @@ -207,7 +207,7 @@ describe("bin/js-transforms - vite", () => { }); }); -describe("bin/js-transforms - webpack", () => { +describe("js replacer - webpack", () => { const jsCodeUntransformed = ` function f() { return a.p+"static/js/" + ({}[e] || e) + "." + { @@ -317,7 +317,7 @@ describe("bin/js-transforms - webpack", () => { }); }); -describe("bin/css-transforms", () => { +describe("css replacer", () => { it("transforms absolute urls to css globals properly with no urlPathname", () => { const { fixedCssCode, cssGlobalsToDefine } = replaceImportsInCssCode({ "cssCode": ` @@ -432,7 +432,7 @@ describe("bin/css-transforms", () => { }); }); -describe("bin/css-inline-transforms", () => { +describe("inline css replacer", () => { describe("no url pathName", () => { const cssCode = ` @font-face {