@scriptdb/system-modules 1.0.3 → 1.0.5
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/dist/index.js +18 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -275,17 +275,34 @@ function save(dbName, code) {
|
|
|
275
275
|
fs4.writeFileSync(dbPath, fileContent, "utf8");
|
|
276
276
|
}
|
|
277
277
|
|
|
278
|
+
// src/modules/read.ts
|
|
279
|
+
import * as fs5 from "fs";
|
|
280
|
+
import * as path5 from "path";
|
|
281
|
+
import * as os5 from "os";
|
|
282
|
+
function read(dbName) {
|
|
283
|
+
const DIR = "databases";
|
|
284
|
+
const basePath = path5.join(os5.homedir(), ".scriptdb");
|
|
285
|
+
const baseDir = path5.resolve(basePath, DIR);
|
|
286
|
+
const dbPath = path5.join(baseDir, `${dbName}.ts`);
|
|
287
|
+
if (!fs5.existsSync(dbPath)) {
|
|
288
|
+
throw new Error(`Database '${dbName}' not found`);
|
|
289
|
+
}
|
|
290
|
+
return fs5.readFileSync(dbPath, "utf8");
|
|
291
|
+
}
|
|
292
|
+
|
|
278
293
|
// src/index.ts
|
|
279
294
|
var update2 = update;
|
|
280
295
|
var remove2 = remove;
|
|
281
296
|
var create2 = create;
|
|
282
297
|
var save2 = save;
|
|
298
|
+
var read2 = read;
|
|
283
299
|
async function SystemModuleResolver() {
|
|
284
300
|
const moduleRegistry = new Map;
|
|
285
301
|
moduleRegistry.set("update", update2);
|
|
286
302
|
moduleRegistry.set("remove", remove2);
|
|
287
303
|
moduleRegistry.set("create", create2);
|
|
288
304
|
moduleRegistry.set("save", save2);
|
|
305
|
+
moduleRegistry.set("read", read2);
|
|
289
306
|
const context = {
|
|
290
307
|
require: (moduleName) => {
|
|
291
308
|
const module = moduleRegistry.get(moduleName);
|
|
@@ -314,6 +331,7 @@ export {
|
|
|
314
331
|
update2 as update,
|
|
315
332
|
save2 as save,
|
|
316
333
|
remove2 as remove,
|
|
334
|
+
read2 as read,
|
|
317
335
|
src_default as default,
|
|
318
336
|
create2 as create,
|
|
319
337
|
SystemModuleResolver
|