Skip to content

Commit

Permalink
path resolve and sub/sub folder module (#3653)
Browse files Browse the repository at this point in the history
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 <github@veeck.de>
  • Loading branch information
bugsounet and rejas authored Dec 18, 2024
1 parent b910c60 commit c485ff6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -178,7 +178,7 @@ function App () {
}
}

const moduleFile = `${moduleFolder}/${module}.js`;
const moduleFile = `${moduleFolder}/${moduleName}.js`;

try {
fs.accessSync(moduleFile, fs.R_OK);
Expand Down

0 comments on commit c485ff6

Please sign in to comment.