@kezh/my-custom-js-converter 0.0.2 → 0.0.4

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.
@@ -1,22 +1,12 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.Config = void 0;
4
- exports.default = {
5
- encode: {
6
- file: "index.js",
7
- output: "coded.js",
8
- entry: "customEvent",
9
- ignoreMod: ["commonUtil"]
10
- },
11
- decode: {
12
- file: "coded.js",
13
- output: "decoded.js",
14
- mount: "customEvent"
15
- },
16
- baseDir: "",
17
- target: [""],
18
- customConfig: "config.json"
19
- };
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ exports.default = config();
20
10
  var Config;
21
11
  (function (Config) {
22
12
  class Mod {
@@ -27,3 +17,34 @@ var Config;
27
17
  }
28
18
  Config.Mod = Mod;
29
19
  })(Config = exports.Config || (exports.Config = {}));
20
+ function config() {
21
+ const defConfig = {
22
+ encode: {
23
+ file: "index.js",
24
+ output: "coded.js",
25
+ entry: "customEvent",
26
+ ignoreMod: ["commonUtil"],
27
+ },
28
+ decode: {
29
+ file: "coded.js",
30
+ output: "decoded.js",
31
+ mount: "customEvent",
32
+ },
33
+ baseDir: "",
34
+ target: [""],
35
+ customConfig: "config.json",
36
+ };
37
+ const curDir = __dirname;
38
+ const baseDir = curDir.replace(/node_modules.*/g, "");
39
+ try {
40
+ const configPath = path_1.default.join(baseDir, defConfig.customConfig);
41
+ fs_1.default.accessSync(configPath);
42
+ const json = fs_1.default.readFileSync(configPath, { encoding: "utf-8" });
43
+ const customConfig = JSON.parse(json);
44
+ defConfig.target = customConfig.target;
45
+ defConfig.encode = customConfig.encode;
46
+ defConfig.decode = customConfig.decode;
47
+ }
48
+ catch (err) { }
49
+ return defConfig;
50
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kezh/my-custom-js-converter",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "自代码转换器",
5
5
  "main": "index.js",
6
6
  "bin": {