masterrecord 0.2.21 → 0.2.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/context.js +11 -7
- package/package.json +1 -1
package/context.js
CHANGED
|
@@ -98,17 +98,19 @@ class context {
|
|
|
98
98
|
let currentRoot = root;
|
|
99
99
|
const maxHops = 12;
|
|
100
100
|
for(let i = 0; i < maxHops; i++){
|
|
101
|
-
const rootFolder = path.isAbsolute(rootFolderLocation) ? rootFolderLocation :
|
|
101
|
+
const rootFolder = path.isAbsolute(rootFolderLocation) ? rootFolderLocation : path.join(currentRoot, rootFolderLocation);
|
|
102
102
|
// Support both env.development.json and development.json naming
|
|
103
103
|
const searchA = `${rootFolder}/**/*env.${envType}.json`;
|
|
104
104
|
const searchB = `${rootFolder}/**/*${envType}.json`;
|
|
105
|
-
let files = globSearch.sync(searchA, currentRoot);
|
|
105
|
+
let files = globSearch.sync(searchA, { cwd: currentRoot, dot: true, nocase: true, windowsPathsNoEscape: true });
|
|
106
106
|
if(!files || files.length === 0){
|
|
107
|
-
files = globSearch.sync(searchB, currentRoot);
|
|
107
|
+
files = globSearch.sync(searchB, { cwd: currentRoot, dot: true, nocase: true, windowsPathsNoEscape: true });
|
|
108
108
|
}
|
|
109
|
-
const
|
|
110
|
-
if(
|
|
111
|
-
|
|
109
|
+
const rel = files && files[0];
|
|
110
|
+
if(rel){
|
|
111
|
+
// Ensure absolute path for require()
|
|
112
|
+
const abs = path.isAbsolute(rel) ? rel : path.resolve(currentRoot, rel);
|
|
113
|
+
return { file: abs, rootFolder: currentRoot };
|
|
112
114
|
}
|
|
113
115
|
const parent = tools.removeBackwardSlashSection(currentRoot, 1, "/");
|
|
114
116
|
if(parent === currentRoot || parent === ""){
|
|
@@ -151,7 +153,9 @@ class context {
|
|
|
151
153
|
throw new Error(`Environment config not found for '${envType}' under '${rootFolderLocation}'.`);
|
|
152
154
|
}
|
|
153
155
|
|
|
154
|
-
|
|
156
|
+
// Always require absolute file path to avoid module root ambiguity on global installs/Windows
|
|
157
|
+
const settingsPath = path.isAbsolute(file.file) ? file.file : path.resolve(file.rootFolder, file.file);
|
|
158
|
+
const settings = require(settingsPath);
|
|
155
159
|
const options = settings[contextName];
|
|
156
160
|
if(options === undefined){
|
|
157
161
|
console.log("settings missing context name settings");
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"app-root-path": "^3.1.0",
|
|
10
10
|
"better-sqlite3": "^12.4.1"
|
|
11
11
|
},
|
|
12
|
-
"version": "0.2.
|
|
12
|
+
"version": "0.2.22",
|
|
13
13
|
"description": "An Object-relational mapping for the Master framework. Master Record connects classes to relational database tables to establish a database with almost zero-configuration ",
|
|
14
14
|
"homepage": "https://github.com/Tailor/MasterRecord#readme",
|
|
15
15
|
"repository": {
|