builder/lib/tasks/createDebugFiles.js

  1. const dbg = require("../processors/debugFileCreator");
  2. const fsInterface = require("@ui5/fs").fsInterface;
  3. /**
  4. * Task to create dbg files.
  5. *
  6. * @public
  7. * @alias module:@ui5/builder.tasks.createDebugFiles
  8. * @param {object} parameters Parameters
  9. * @param {module:@ui5/fs.DuplexCollection} parameters.workspace DuplexCollection to read and write files
  10. * @param {object} parameters.options Options
  11. * @param {string} parameters.options.pattern Pattern to locate the files to be processed
  12. * @returns {Promise<undefined>} Promise resolving with <code>undefined</code> once data has been written
  13. */
  14. module.exports = async function({workspace, options: {pattern}}) {
  15. let allResources;
  16. if (workspace.byGlobSource) { // API only available on duplex collections
  17. allResources = await workspace.byGlobSource(pattern);
  18. } else {
  19. allResources = await workspace.byGlob(pattern);
  20. }
  21. return dbg({
  22. fs: fsInterface(workspace),
  23. resources: allResources
  24. }).then((processedResources) => {
  25. return Promise.all(processedResources.map((resource) => {
  26. return workspace.write(resource);
  27. }));
  28. });
  29. };