binhend 2.1.5 → 2.1.7
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/package.json +1 -1
- package/src/web/component.format.js +18 -1
- package/src/web/index.js +6 -1
package/package.json
CHANGED
|
@@ -37,7 +37,7 @@ function generate(sourceRootPath, outputRootPath, callbackDone) {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
var content = readFileSync(fileSourcePath, { encoding: 'utf8', flag: 'r' });
|
|
40
|
-
var code = PREFIX_CODE + content.trim() + '\r\n\r\n;binh.final(module);';
|
|
40
|
+
var code = PREFIX_CODE + mapConfigValues(content.trim()) + '\r\n\r\n;binh.final(module);';
|
|
41
41
|
|
|
42
42
|
writeToFileIfNew(fileOutputPath, code);
|
|
43
43
|
}
|
|
@@ -47,6 +47,23 @@ function generate(sourceRootPath, outputRootPath, callbackDone) {
|
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
function mapConfigValues(content) {
|
|
51
|
+
var matches = content.matchAll(/{\/\*(.+?)\*\/}/g); // match all terms wrapped in format: {/*TERM*/}
|
|
52
|
+
|
|
53
|
+
var map = {};
|
|
54
|
+
|
|
55
|
+
for (var match of matches) {
|
|
56
|
+
map[match[1]] = true;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
Object.keys(map).forEach((key) => {
|
|
60
|
+
if (!config.hasOwnProperty(key)) return;
|
|
61
|
+
content = content.replaceAll(`{/*${key}*/}`, config[key]);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
return content;
|
|
65
|
+
}
|
|
66
|
+
|
|
50
67
|
module.exports = {
|
|
51
68
|
generate
|
|
52
69
|
};
|
package/src/web/index.js
CHANGED
|
@@ -14,7 +14,7 @@ function WebBuilder(source, { output, external } = {}) {
|
|
|
14
14
|
source = path.resolve(source);
|
|
15
15
|
output = isString(output) ? output : 'build';
|
|
16
16
|
|
|
17
|
-
if (source === path.resolve(output)) throw new Error(`[BINHEND][WEB] Location of build output & source code should
|
|
17
|
+
if (source === path.resolve(output)) throw new Error(`[BINHEND][WEB] Location of build output & source code should NOT be the same: ${source}`);
|
|
18
18
|
|
|
19
19
|
var module = path.resolve(output, 'module');
|
|
20
20
|
var web = path.resolve(output, 'web');
|
|
@@ -28,6 +28,11 @@ function WebBuilder(source, { output, external } = {}) {
|
|
|
28
28
|
ComponentFormat.generate(source, module, () => ComponentBuild.lazyload({ source, web, module, external }));
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
+
this.modulify = (outputModulePath) => {
|
|
32
|
+
outputModulePath = isString(outputModulePath) ? path.resolve(outputModulePath) : module;
|
|
33
|
+
ComponentFormat.generate(source, outputModulePath);
|
|
34
|
+
};
|
|
35
|
+
|
|
31
36
|
this.path = () => {
|
|
32
37
|
return web;
|
|
33
38
|
};
|