From 9f25cddaa46f034708ba7f4043ce9d4e37e99bc2 Mon Sep 17 00:00:00 2001 From: rome-user <114131048+rome-user@users.noreply.github.com> Date: Sun, 8 Oct 2023 18:12:57 -0700 Subject: [PATCH] Allow "keycloak_theme" as a theme source directory Fixes #429. --- src/bin/getSrcDirPath.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/bin/getSrcDirPath.ts b/src/bin/getSrcDirPath.ts index 893e29b1..115cc89b 100644 --- a/src/bin/getSrcDirPath.ts +++ b/src/bin/getSrcDirPath.ts @@ -4,7 +4,7 @@ import { crawl } from "./tools/crawl"; import { join as pathJoin } from "path"; import { themeTypes } from "./keycloakify/generateFtl"; -const themeSrcDirBasename = "keycloak-theme"; +const themeSrcDirBasenames = ["keycloak-theme", "keycloak_theme"]; /** Can't catch error, if the directory isn't found, this function will just exit the process with an error message. */ export function getThemeSrcDirPath(params: { projectDirPath: string }) { @@ -14,13 +14,13 @@ export function getThemeSrcDirPath(params: { projectDirPath: string }) { const themeSrcDirPath: string | undefined = crawl({ "dirPath": srcDirPath, "returnedPathsType": "relative to dirPath" }) .map(fileRelativePath => { - const split = fileRelativePath.split(themeSrcDirBasename); - - if (split.length !== 2) { - return undefined; + for (const themeSrcDirBasename of themeSrcDirBasenames) { + const split = fileRelativePath.split(themeSrcDirBasename); + if (split.length === 2) { + return pathJoin(srcDirPath, split[0] + themeSrcDirBasename); + } } - - return pathJoin(srcDirPath, split[0] + themeSrcDirBasename); + return undefined; }) .filter(exclude(undefined))[0]; @@ -38,7 +38,7 @@ export function getThemeSrcDirPath(params: { projectDirPath: string }) { console.error( [ "Can't locate your theme source directory. It should be either: ", - "src/ or src/keycloak-theme.", + "src/ or src/keycloak-theme or src/keycloak_theme.", "Example in the starter: https://github.com/keycloakify/keycloakify-starter/tree/main/src/keycloak-theme" ].join("\n") );