Skip to content

Commit 8af8a75

Browse files
committed
test(project): Address review of @RandomByte
1 parent 7e31f68 commit 8af8a75

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
1+
const Logger = require("@ui5/logger");
2+
const log = Logger.getLogger("builder:tasks:customTask0");
3+
14
let buildRanOnce;
25
module.exports = async function ({
36
workspace, taskUtil,
47
options: {projectNamespace}
58
}) {
6-
console.log("Custom task 0 executed");
9+
log.verbose("Custom task 0 executed");
710

811
// Read a file to trigger execution of this task:
912
const testJS = await workspace.byPath(`/resources/${projectNamespace}/test.js`);
1013

1114
if (buildRanOnce != true) {
12-
console.log("Flag NOT set -> We are in #1 Build still");
15+
log.verbose("Flag NOT set -> We are in #1 Build still");
1316
buildRanOnce = true;
1417
taskUtil.setTag(testJS, taskUtil.STANDARD_TAGS.IsDebugVariant);
1518
} else {
16-
console.log("Flag set -> We are in #2 Build");
19+
log.verbose("Flag set -> We are in #2 Build");
1720
taskUtil.setTag(testJS, taskUtil.STANDARD_TAGS.OmitFromBuildResult);
1821
}
1922
};

packages/project/test/fixtures/application.a/custom-tasks-2/custom-task-1.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
1+
const Logger = require("@ui5/logger");
2+
const log = Logger.getLogger("builder:tasks:customTask1");
3+
14
let buildRanOnce;
25
module.exports = async function ({
36
workspace, taskUtil,
47
options: {projectNamespace}
58
}) {
6-
console.log("Custom task 1 executed");
9+
log.verbose("Custom task 1 executed");
710

811
// Read a file to trigger execution of this task:
912
const testJS = await workspace.byPath(`/resources/${projectNamespace}/test.js`);
1013

1114
if (buildRanOnce != true) {
12-
console.log("Flag NOT set -> We are in #1 Build still");
15+
log.verbose("Flag NOT set -> We are in #1 Build still");
1316
buildRanOnce = true;
1417
const tag = taskUtil.getTag(testJS, taskUtil.STANDARD_TAGS.IsDebugVariant);
1518
if (!tag) {
1619
throw new Error("Tag set during #1 Build is not readable, which is UNEXPECTED.");
1720
}
1821
} else {
19-
console.log("Flag set -> We are in #2 Build");
22+
const previousTag = taskUtil.getTag(testJS, taskUtil.STANDARD_TAGS.IsDebugVariant);
23+
if (previousTag) {
24+
throw new Error("Tag set during #1 Build is still readable, which is UNEXPECTED.");
25+
}
26+
log.verbose("Flag set -> We are in #2 Build");
2027
const tag = taskUtil.getTag(testJS, taskUtil.STANDARD_TAGS.OmitFromBuildResult);
2128
if (!tag) {
2229
throw new Error("Tag set during #2 Build is not readable, which is UNEXPECTED.");

packages/project/test/fixtures/application.a/task.dependency-change.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
// This is a modified version of the compileLicenseSummary example of the UI5 CLI.
1+
// This is a modified version of the compileLicenseSummary example of the UI5 CLI documentation.
22
// (https://github.com/UI5/cli/blob/b72919469d856508dd757ecf325a5fb45f15e56d/internal/documentation/docs/pages/extensibility/CustomTasks.md#example-libtaskscompilelicensesummaryjs)
33

4-
module.exports = async function ({dependencies, log, taskUtil, workspace, options: {projectNamespace}}) {
4+
module.exports = async function ({log, taskUtil, workspace}) {
55
const {createResource} = taskUtil.resourceFactory;
66
const projectsVisited = new Set();
77

8-
async function processProject(project) {
8+
async function processProject() {
99
return Promise.all(taskUtil.getDependencies().map(async (projectName) => {
1010
if (projectName !== "library.d") {
1111
return;
@@ -17,7 +17,7 @@ module.exports = async function ({dependencies, log, taskUtil, workspace, option
1717
const project = taskUtil.getProject(projectName);
1818
const newLibraryFile = await project.getReader().byGlob("**/newLibraryFile.js");
1919
if (newLibraryFile.length > 0) {
20-
console.log('New Library file found. We are in #4 build.');
20+
log.verbose('New Library file found. We are in #4 build.');
2121
// Change content of application.a:
2222
const applicationResource = await workspace.byPath("/resources/id1/test.js");
2323
const content = (await applicationResource.getString()) + "\n console.log('something new');";
@@ -26,7 +26,7 @@ module.exports = async function ({dependencies, log, taskUtil, workspace, option
2626
string: content
2727
}));
2828
} else {
29-
console.log(`New Library file not found. We are still in an earlier build.`);
29+
log.verbose(`New Library file not found. We are still in an earlier build.`);
3030
}
3131
return processProject(project);
3232
}));

0 commit comments

Comments
 (0)