mobiletto-orm-typedef-gen 2.1.31 → 2.1.32

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.
@@ -146,7 +146,19 @@ export const generate = (typeDef, templatePath, opts) => {
146
146
  if (!templatePath.endsWith(".ts.hbs")) {
147
147
  throw new MobilettoOrmError(`invalid template path: ${templatePath}`);
148
148
  }
149
- const template = fs.readFileSync(__dirname + "/" + templatePath).toString("utf8");
149
+ const localTemplate = __dirname + "/" + templatePath;
150
+ let template;
151
+ try {
152
+ template = fs.readFileSync(localTemplate).toString("utf8");
153
+ }
154
+ catch (e) {
155
+ try {
156
+ template = fs.readFileSync(templatePath).toString("utf8");
157
+ }
158
+ catch (e2) {
159
+ throw new MobilettoOrmError(`template path not found: ${templatePath}`);
160
+ }
161
+ }
150
162
  const data = Handlebars.compile(template)(preparedContext);
151
163
  allData = data + allData;
152
164
  }
@@ -1,8 +1,8 @@
1
1
  {
2
- "name": "mobiletto-orm-typedef",
2
+ "name": "mobiletto-orm-typedef-gen",
3
3
  "type": "commonjs",
4
4
  "main": "./index.js",
5
- "homepage": "https://github.com/cobbzilla/mobiletto-orm-typedef",
5
+ "homepage": "https://github.com/cobbzilla/mobiletto-orm-typedef-gen",
6
6
  "author": "Jonathan Cobb <udo9jqld@duck.com> (https://github.com/cobbzilla)",
7
7
  "funding": {
8
8
  "type": "patreon",
@@ -10,7 +10,7 @@
10
10
  },
11
11
  "repository": {
12
12
  "type": "git",
13
- "url": "https://github.com/cobbzilla/mobiletto-orm-typedef.git"
13
+ "url": "https://github.com/cobbzilla/mobiletto-orm-typedef-gen.git"
14
14
  },
15
15
  "license": "Apache-2.0"
16
16
  }
@@ -146,7 +146,19 @@ export const generate = (typeDef, templatePath, opts) => {
146
146
  if (!templatePath.endsWith(".ts.hbs")) {
147
147
  throw new MobilettoOrmError(`invalid template path: ${templatePath}`);
148
148
  }
149
- const template = fs.readFileSync(__dirname + "/" + templatePath).toString("utf8");
149
+ const localTemplate = __dirname + "/" + templatePath;
150
+ let template;
151
+ try {
152
+ template = fs.readFileSync(localTemplate).toString("utf8");
153
+ }
154
+ catch (e) {
155
+ try {
156
+ template = fs.readFileSync(templatePath).toString("utf8");
157
+ }
158
+ catch (e2) {
159
+ throw new MobilettoOrmError(`template path not found: ${templatePath}`);
160
+ }
161
+ }
150
162
  const data = Handlebars.compile(template)(preparedContext);
151
163
  allData = data + allData;
152
164
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobiletto-orm-typedef-gen",
3
- "version": "2.1.31",
3
+ "version": "2.1.32",
4
4
  "type": "module",
5
5
  "exports": "./lib/esm/index.js",
6
6
  "description": "generate various files based on mobiletto-orm-typedef definitions",