-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
41 lines (41 loc) · 4.07 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const rxjs_1 = require("rxjs");
const list_dir_file_1 = require("list-dir-file");
const handlebars_1 = require("handlebars");
const path_1 = require("path");
const fs_1 = require("fs");
const operators_1 = require("rxjs/operators");
const core_1 = require("@angular-devkit/core");
const logger = new core_1.logging.IndentLogger('create');
function iwe7Template(sourcePath, destPath, options) {
const templateRoot = core_1.normalize(sourcePath);
const outputPath = core_1.normalize(destPath);
logger.subscribe(res => {
console.log(`${core_1.terminal.red(`${res.name}`)} ${core_1.terminal.green(res.message)}`);
});
return list_dir_file_1.listDir(sourcePath).pipe(operators_1.map(res => core_1.normalize(res.replace(path_1.extname(res), ''))), operators_1.map(res => core_1.relative(templateRoot, res)), operators_1.switchMap(filename => {
return rxjs_1.of(fs_1.readFileSync(core_1.join(templateRoot, filename + '.imeepos')).toString('utf-8')).pipe(operators_1.map(fileContent => {
return {
filename: iwe7Compiler(filename, options),
content: iwe7Compiler(fileContent, options)
};
}), operators_1.tap(res => {
const file = core_1.join(outputPath, res.filename);
const filePath = path_1.dirname(file);
if (!fs_1.existsSync(filePath)) {
fs_1.mkdirSync(filePath);
}
fs_1.writeFileSync(file, res.content);
logger.info(`${res.filename}`);
}));
}));
}
exports.iwe7Template = iwe7Template;
function iwe7Compiler(source, options) {
const template = handlebars_1.compile(source);
const tmpl = template(options);
return tmpl;
}
exports.iwe7Compiler = iwe7Compiler;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiLi8iLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQUEsK0JBQTBCO0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