@kezh/my-custom-js-converter 1.1.1 → 1.1.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.
- package/core/decode/index.js +3 -2
- package/core/util/ast.js +4 -2
- package/package.json +1 -1
package/core/decode/index.js
CHANGED
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const path_1 = __importDefault(require("path"));
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const os_1 = require("os");
|
|
8
9
|
const prettier_1 = __importDefault(require("prettier"));
|
|
9
10
|
const config_1 = require("../config");
|
|
10
11
|
const scanf_1 = require("../scanf");
|
|
@@ -36,7 +37,7 @@ function decoding$0(inPath, outPath, config) {
|
|
|
36
37
|
let src = fs_1.default.readFileSync(inPath, {
|
|
37
38
|
encoding: "utf-8"
|
|
38
39
|
});
|
|
39
|
-
src = `const ${config.decode.mount} = {${src}}
|
|
40
|
+
src = `const ${config.decode.mount} = {${src}};${os_1.EOL}module.exports = ${config.decode.mount};`;
|
|
40
41
|
const srcAst = (0, parser_1.parse)(src);
|
|
41
42
|
if (!core_1.types.isNode(srcAst)) {
|
|
42
43
|
return;
|
|
@@ -44,7 +45,7 @@ function decoding$0(inPath, outPath, config) {
|
|
|
44
45
|
(0, ast_1.importMods)(path_1.default.dirname(outPath), srcAst, mapContext);
|
|
45
46
|
(0, ast_1.deleteModMethods)(srcAst, mapContext);
|
|
46
47
|
let { code: dist } = (0, generator_1.default)(srcAst, { compact: true });
|
|
47
|
-
dist = dist.replace(/},\n\n/g,
|
|
48
|
+
dist = dist.replace(/},\n\n/g, `},${os_1.EOL}`);
|
|
48
49
|
dist = prettier_1.default.format(dist, {
|
|
49
50
|
parser: "babel",
|
|
50
51
|
trailingComma: "none"
|
package/core/util/ast.js
CHANGED
|
@@ -11,6 +11,7 @@ const generator_1 = __importDefault(require("@babel/generator"));
|
|
|
11
11
|
const core_1 = require("@babel/core");
|
|
12
12
|
const scanf_1 = require("../scanf");
|
|
13
13
|
const path_1 = require("path");
|
|
14
|
+
const os_1 = require("os");
|
|
14
15
|
function parseSrcAst(srcPath) {
|
|
15
16
|
if (!srcPath) {
|
|
16
17
|
return;
|
|
@@ -22,7 +23,7 @@ function parseSrcAst(srcPath) {
|
|
|
22
23
|
}
|
|
23
24
|
exports.parseSrcAst = parseSrcAst;
|
|
24
25
|
function outputObjectMethods(outPath, methods) {
|
|
25
|
-
|
|
26
|
+
let dist = methods
|
|
26
27
|
.map((m) => {
|
|
27
28
|
var _a;
|
|
28
29
|
if ((_a = m.leadingComments) === null || _a === void 0 ? void 0 : _a.length) {
|
|
@@ -32,7 +33,8 @@ function outputObjectMethods(outPath, methods) {
|
|
|
32
33
|
})
|
|
33
34
|
.map((m) => (0, generator_1.default)(m))
|
|
34
35
|
.map((m) => m.code)
|
|
35
|
-
.join(
|
|
36
|
+
.join(`,\n`);
|
|
37
|
+
dist = dist.replace(/\n/gm, os_1.EOL);
|
|
36
38
|
fs_1.default.writeFileSync(outPath, dist, "utf-8");
|
|
37
39
|
}
|
|
38
40
|
exports.outputObjectMethods = outputObjectMethods;
|