From c485ff670d03b26d652a7d74ef49158433bd9041 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bugsounet=20-=20C=C3=A9dric?= Date: Wed, 18 Dec 2024 22:07:09 +0100 Subject: [PATCH] path resolve and sub/sub folder module (#3653) Fix: - use `path.resolve` for `moduleFolder` and `defaultModuleFolder` path - Fix module path in case of sub/sub folder is used (sample `module/test/test`) --- case of module installation on `module/test/test`: config will be: ```js { module: "test/test", ... } ``` module core will be: ```js Module.register("test", { ... ``` `test.js` is used for module core (no change) --- case of module installation on `module/test` (no change): config will be: ```js { module: "test", ... } ``` module core will be: ```js Module.register("test", { ... ``` so `test.js` is used for module core --- In reality, with this patch, `module` config feature have 2 functionalites: - determinate module path with more precision - allow to use sub/sub folder in modules folder --------- Co-authored-by: Veeck --- CHANGELOG.md | 1 + js/app.js | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c895706..1d71ff63 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,7 @@ _This release is scheduled to be released on 2025-01-01._ - [core] Fix missing `basePath` where `location.host` is used (#3613) - [compliments] croner library changed filenames used in latest version (#3624) - [linter] Fix ESLint ignore pattern which caused that default modules not to be linted (#3632) +- [core] Fix module path in case of sub/sub folder is used and use path.resolve for resolve `moduleFolder` and `defaultModuleFolder` in app.js (#3653) - [calendar] Update to resolve issues #3098 #3144 #3351 #3422 #3443 #3467 #3537 related to timezone changes - [calendar] Fix #3267 (styles array), also fixes event with both exdate AND recurrence(and testcase) - [calendar] Fix showEndsOnlyWithDuration not working, #3598, applies ONLY to full day events diff --git a/js/app.js b/js/app.js index 9d111c7e..0c2586af 100644 --- a/js/app.js +++ b/js/app.js @@ -164,10 +164,10 @@ function App () { const elements = module.split("/"); const moduleName = elements[elements.length - 1]; const env = getEnvVarsAsObj(); - let moduleFolder = `${__dirname}/../${env.modulesDir}/${module}`; + let moduleFolder = path.resolve(`${__dirname}/../${env.modulesDir}`, module); if (defaultModules.includes(moduleName)) { - const defaultModuleFolder = `${__dirname}/../modules/default/${module}`; + const defaultModuleFolder = path.resolve(`${__dirname}/../modules/default/`, module); if (process.env.JEST_WORKER_ID === undefined) { moduleFolder = defaultModuleFolder; } else { @@ -178,7 +178,7 @@ function App () { } } - const moduleFile = `${moduleFolder}/${module}.js`; + const moduleFile = `${moduleFolder}/${moduleName}.js`; try { fs.accessSync(moduleFile, fs.R_OK);