@ghom/orm 1.2.2 → 1.2.3

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.
@@ -23,7 +23,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
23
23
  };
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
25
  exports.ORM = void 0;
26
+ const fs_1 = __importDefault(require("fs"));
26
27
  const url_1 = __importDefault(require("url"));
28
+ const path_1 = __importDefault(require("path"));
27
29
  const handler_1 = require("@ghom/handler");
28
30
  const knex_1 = __importDefault(require("knex"));
29
31
  const table_js_1 = require("./table.js");
@@ -47,7 +49,9 @@ class ORM extends handler_1.Handler {
47
49
  async init() {
48
50
  this.once("finish", async (pathList) => {
49
51
  const tables = await Promise.all(pathList.map(async (filepath) => {
50
- return Promise.resolve().then(() => __importStar(require(require !== void 0 ? filepath : url_1.default.pathToFileURL(filepath).href))).then((file) => file.default);
52
+ return Promise.resolve().then(() => __importStar(require(fs_1.default.existsSync(path_1.default.join(__dirname, "..", "..", "cjs"))
53
+ ? filepath
54
+ : url_1.default.pathToFileURL(filepath).href))).then((file) => file.default);
51
55
  }));
52
56
  const migration = new table_js_1.Table({
53
57
  name: "migration",
@@ -1,4 +1,6 @@
1
+ import fs from "fs";
1
2
  import url from "url";
3
+ import path from "path";
2
4
  import { Handler } from "@ghom/handler";
3
5
  import { default as knex } from "knex";
4
6
  import { Table } from "./table.js";
@@ -24,7 +26,9 @@ export class ORM extends Handler {
24
26
  async init() {
25
27
  this.once("finish", async (pathList) => {
26
28
  const tables = await Promise.all(pathList.map(async (filepath) => {
27
- return import(require !== void 0 ? filepath : url.pathToFileURL(filepath).href).then((file) => file.default);
29
+ return import(fs.existsSync(path.join(__dirname, "..", "..", "cjs"))
30
+ ? filepath
31
+ : url.pathToFileURL(filepath).href).then((file) => file.default);
28
32
  }));
29
33
  const migration = new Table({
30
34
  name: "migration",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ghom/orm",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "license": "MIT",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
package/src/app/orm.ts CHANGED
@@ -1,4 +1,6 @@
1
+ import fs from "fs"
1
2
  import url from "url"
3
+ import path from "path"
2
4
  import { Handler } from "@ghom/handler"
3
5
  import { Knex, default as knex } from "knex"
4
6
  import { MigrationData, Table } from "./table.js"
@@ -46,7 +48,9 @@ export class ORM extends Handler {
46
48
  const tables: Table<any>[] = await Promise.all(
47
49
  pathList.map(async (filepath) => {
48
50
  return import(
49
- require !== void 0 ? filepath : url.pathToFileURL(filepath).href
51
+ fs.existsSync(path.join(__dirname, "..", "..", "cjs"))
52
+ ? filepath
53
+ : url.pathToFileURL(filepath).href
50
54
  ).then((file) => file.default)
51
55
  })
52
56
  )