Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
handleTask(extension) {
if (!extension.metadata && !extension.metadata.name) {
throw new Error(`Task extension ${extension.id} is missing 'metadata.name' configuration`);
}
if (!extension.task) {
throw new Error(`Task extension ${extension.id} is missing 'task' configuration`);
}
const taskRepository = require("@ui5/builder").tasks.taskRepository;
const taskPath = path.join(extension.path, extension.task.path);
const task = require(taskPath); // throws if not found
taskRepository.addTask(extension.metadata.name, task);
}
return projectPreprocessor.processTree(tree).then((parsedTree) => {
t.deepEqual(parsedTree.dependencies.length, 0, "Application project has no dependencies");
const taskRepository = require("@ui5/builder").tasks.taskRepository;
t.truthy(taskRepository.getTask("task.a"), "task.a has been added to the task repository");
});
});
const log = require("@ui5/logger").getLogger("normalizer:projectPreprocessor");
const fs = require("graceful-fs");
const path = require("path");
const {promisify} = require("util");
const readFile = promisify(fs.readFile);
const parseYaml = require("js-yaml").safeLoadAll;
const typeRepository = require("@ui5/builder").types.typeRepository;
class ProjectPreprocessor {
constructor() {
this.processedProjects = {};
this.configShims = {};
this.collections = {};
this.appliedExtensions = {};
}
/*
Adapt and enhance the project tree:
- Replace duplicate projects further away from the root with those closer to the root
- Add configuration to projects
*/
async processTree(tree) {
const queue = [{