@kezh/my-custom-js-converter 0.0.5 → 0.0.6
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/core/config/index.js +1 -0
- package/core/decode.js +4 -1
- package/package.json +1 -1
package/core/config/index.js
CHANGED
|
@@ -41,6 +41,7 @@ function config() {
|
|
|
41
41
|
fs_1.default.accessSync(configPath);
|
|
42
42
|
const json = fs_1.default.readFileSync(configPath, { encoding: "utf-8" });
|
|
43
43
|
const customConfig = JSON.parse(json);
|
|
44
|
+
defConfig.baseDir = baseDir;
|
|
44
45
|
defConfig.target = customConfig.target;
|
|
45
46
|
defConfig.encode = customConfig.encode;
|
|
46
47
|
defConfig.decode = customConfig.decode;
|
package/core/decode.js
CHANGED
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const fs_1 = __importDefault(require("fs"));
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
|
+
const prettier_1 = __importDefault(require("prettier"));
|
|
8
9
|
const parser_1 = require("@babel/parser");
|
|
9
10
|
const traverse_1 = __importDefault(require("@babel/traverse"));
|
|
10
11
|
const generator_1 = __importDefault(require("@babel/generator"));
|
|
@@ -42,7 +43,9 @@ function decoding$0(inPath, outPath, mount = MOUNT) {
|
|
|
42
43
|
const srcAst = (0, parser_1.parse)(src);
|
|
43
44
|
importMods(path_1.default.dirname(outPath), customConfig.mod, srcAst);
|
|
44
45
|
deleteModMethods(customConfig.mod, srcAst);
|
|
45
|
-
|
|
46
|
+
let { code: dist } = (0, generator_1.default)(srcAst);
|
|
47
|
+
dist = dist.replace(/},\n\n/g, '},\n');
|
|
48
|
+
dist = prettier_1.default.format(dist);
|
|
46
49
|
fs_1.default.writeFileSync(outPath, dist, "utf-8");
|
|
47
50
|
}
|
|
48
51
|
function importMods(outDir, mods, srcAst) {
|