forked from SAP/ui5-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateDebugFiles.js
30 lines (29 loc) · 1.08 KB
/
createDebugFiles.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
const dbg = require("../processors/debugFileCreator");
const fsInterface = require("@ui5/fs").fsInterface;
/**
* Task to create dbg files.
*
* @public
* @alias module:@ui5/builder.tasks.createDebugFiles
* @param {Object} parameters Parameters
* @param {module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files
* @param {Object} [parameters.options] Options
* @param {string} [parameters.options.pattern] Pattern to locate the files to be processed
* @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
*/
module.exports = async function({workspace, options}) {
let allResources;
if (workspace.byGlobSource) { // API only available on duplex collections
allResources = await workspace.byGlobSource(options.pattern);
} else {
allResources = await workspace.byGlob(options.pattern);
}
return dbg({
fs: fsInterface(workspace),
resources: allResources
}).then((processedResources) => {
return Promise.all(processedResources.map((resource) => {
return workspace.write(resource);
}));
});
};