config2ts 2.2.5 → 2.2.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/config/ini-file.ini.ts +7 -7
- package/config/toml_file.toml.ts +6 -6
- package/config/total.ts +13 -13
- package/package.json +1 -1
- package/src/config2ts.js +2 -2
- package/tests/config2ts.spec.js +1 -1
package/config/ini-file.ini.ts
CHANGED
package/config/toml_file.toml.ts
CHANGED
package/config/total.ts
CHANGED
|
@@ -103,13 +103,13 @@ export namespace DataCsv {
|
|
|
103
103
|
};
|
|
104
104
|
|
|
105
105
|
export const IniFileIni = {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
106
|
+
num: 1,
|
|
107
|
+
str: 'string',
|
|
108
|
+
bool: true,
|
|
109
|
+
ItemType: {
|
|
110
|
+
book: 1,
|
|
111
|
+
fruit: 2,
|
|
112
|
+
},
|
|
113
113
|
};
|
|
114
114
|
|
|
115
115
|
export namespace NoIdCsv {
|
|
@@ -141,10 +141,10 @@ export namespace NoIdCsv {
|
|
|
141
141
|
};
|
|
142
142
|
|
|
143
143
|
export const TomlFileToml = {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
144
|
+
num: 1,
|
|
145
|
+
str: 'test',
|
|
146
|
+
ItemType: {
|
|
147
|
+
book: 1,
|
|
148
|
+
fruit: 2,
|
|
149
|
+
},
|
|
150
150
|
};
|
package/package.json
CHANGED
package/src/config2ts.js
CHANGED
|
@@ -13,14 +13,14 @@ var IndexStr = 'Index';
|
|
|
13
13
|
exports.Convert = {
|
|
14
14
|
ini: function (str, moduleName) {
|
|
15
15
|
var obj = toml.parse(str);
|
|
16
|
-
return "export const ".concat(moduleName, " = ").concat(
|
|
16
|
+
return "export const ".concat(moduleName, " = ").concat(json5.stringify(obj, null, 4), ";");
|
|
17
17
|
},
|
|
18
18
|
csv: function (str, moduleName) {
|
|
19
19
|
return csv2ts(str, moduleName);
|
|
20
20
|
},
|
|
21
21
|
toml: function (str, moduleName) {
|
|
22
22
|
var obj = toml.parse(str);
|
|
23
|
-
return "export const ".concat(moduleName, " = ").concat(
|
|
23
|
+
return "export const ".concat(moduleName, " = ").concat(json5.stringify(obj, null, 4), ";");
|
|
24
24
|
}
|
|
25
25
|
};
|
|
26
26
|
function csv2ts(csvString, moduleName) {
|
package/tests/config2ts.spec.js
CHANGED
|
@@ -10,13 +10,13 @@ test('convert csv file with id', function () {
|
|
|
10
10
|
expect(config2ts.GetTsString('./config/data.csv').replace(reg, '')).toBe(getTsFileString('./config/data.csv.ts'));
|
|
11
11
|
});
|
|
12
12
|
test('convert csv file without id', function () {
|
|
13
|
-
// console.log(config2ts.GetTsString('./config/no-id.csv'))
|
|
14
13
|
expect(config2ts.GetTsString('./config/no-id.csv').replace(reg, '')).toBe(getTsFileString('./config/no-id.csv.ts'));
|
|
15
14
|
});
|
|
16
15
|
test('convert ini file', function () {
|
|
17
16
|
expect(config2ts.GetTsString('./config/ini-file.ini').replace(reg, '')).toBe(getTsFileString('./config/ini-file.ini.ts'));
|
|
18
17
|
});
|
|
19
18
|
test('convert toml file', function () {
|
|
19
|
+
// console.log(config2ts.GetTsString('./config/toml_file.toml'))
|
|
20
20
|
expect(config2ts.GetTsString('./config/toml_file.toml').replace(reg, '')).toBe(getTsFileString('./config/toml_file.toml.ts'));
|
|
21
21
|
});
|
|
22
22
|
test('config2ts merge csv file list', function () {
|