-
Notifications
You must be signed in to change notification settings - Fork 0
/
task.js
27 lines (20 loc) · 784 Bytes
/
task.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
const resourceFactory = require("@ui5/fs").resourceFactory;
module.exports = async function({workspace, dependencies, options}) {
const handlebars = await workspace.byGlob("/resources/*.hbs");
console.log(handlebars); // "/resources/Other.lit.js" is found but should not
const resources = handlebars.map(async hbs => {
const hbsCode = await hbs.getString();
const componentNameMatcher = /(\w+)(\.hbs)/gim;
const result = componentNameMatcher.exec(hbs.getPath());
if (!result) {
return Promise.resolve();
}
const componentName = result[1];
const resource = resourceFactory.createResource({
string: hbsCode,
path: `/resources/generated/templates/${componentName}.lit.js`
});
return workspace.write(resource);
});
return Promise.all(resources);
};