masterrecord 0.2.22 → 0.2.23
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 +21 -7
- package/package.json +1 -1
package/context.js
CHANGED
|
@@ -112,7 +112,7 @@ class context {
|
|
|
112
112
|
const abs = path.isAbsolute(rel) ? rel : path.resolve(currentRoot, rel);
|
|
113
113
|
return { file: abs, rootFolder: currentRoot };
|
|
114
114
|
}
|
|
115
|
-
const parent =
|
|
115
|
+
const parent = path.dirname(currentRoot);
|
|
116
116
|
if(parent === currentRoot || parent === ""){
|
|
117
117
|
break;
|
|
118
118
|
}
|
|
@@ -166,11 +166,15 @@ class context {
|
|
|
166
166
|
|
|
167
167
|
if(type === 'sqlite' || type === 'better-sqlite3'){
|
|
168
168
|
this.isSQLite = true; this.isMySQL = false;
|
|
169
|
-
//
|
|
169
|
+
// Treat leading project-style paths ('/components/...') as project-root relative across OSes
|
|
170
170
|
let dbPath = options.connection || '';
|
|
171
171
|
if(dbPath){
|
|
172
|
-
|
|
173
|
-
|
|
172
|
+
const looksProjectRootRelative = dbPath.startsWith('/') || dbPath.startsWith('\\');
|
|
173
|
+
const isAbsoluteFsPath = path.isAbsolute(dbPath);
|
|
174
|
+
if(looksProjectRootRelative || !isAbsoluteFsPath){
|
|
175
|
+
// Normalize leading separators to avoid duplicating separators on Windows
|
|
176
|
+
const trimmed = dbPath.replace(/^[/\\]+/, '');
|
|
177
|
+
dbPath = path.join(file.rootFolder, trimmed);
|
|
174
178
|
}
|
|
175
179
|
}
|
|
176
180
|
const dbDir = path.dirname(dbPath);
|
|
@@ -214,11 +218,21 @@ class context {
|
|
|
214
218
|
}
|
|
215
219
|
|
|
216
220
|
this.validateSQLiteOptions(options);
|
|
217
|
-
|
|
218
|
-
|
|
221
|
+
// Build DB path similarly to env(): project-root relative on leading slash
|
|
222
|
+
let dbPath = options.connection || '';
|
|
223
|
+
if(dbPath){
|
|
224
|
+
const looksProjectRootRelative = dbPath.startsWith('/') || dbPath.startsWith('\\');
|
|
225
|
+
const isAbsoluteFsPath = path.isAbsolute(dbPath);
|
|
226
|
+
if(looksProjectRootRelative || !isAbsoluteFsPath){
|
|
227
|
+
const trimmed = dbPath.replace(/^[/\\]+/, '');
|
|
228
|
+
dbPath = path.join(file.rootFolder, trimmed);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
options.completeConnection = dbPath;
|
|
232
|
+
var dbDirectory = path.dirname(options.completeConnection);
|
|
219
233
|
|
|
220
234
|
if (!fs.existsSync(dbDirectory)){
|
|
221
|
-
fs.mkdirSync(dbDirectory);
|
|
235
|
+
fs.mkdirSync(dbDirectory, { recursive: true });
|
|
222
236
|
}
|
|
223
237
|
|
|
224
238
|
this.db = this.__SQLiteInit(options, "better-sqlite3");
|
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.23",
|
|
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": {
|