Skip to content

Commit

Permalink
Migrate from boolean flag to enum
Browse files Browse the repository at this point in the history
  • Loading branch information
d3xter666 committed Nov 30, 2023
1 parent aabda03 commit 936e6a7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
18 changes: 9 additions & 9 deletions lib/cli/commands/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,16 @@ build.builder = function(cli) {
default: false,
type: "boolean"
})
.option("flat-output", {
.option("output-style", {
describe:
"Write the build results into a flat directory structure, omitting the project" +
"namespace and the \"resources\" directory." +
"This is currently only supported for projects of type 'library' and projects of " +
"type 'application' always result in flat output." +
"The way build results into a specific directory structure. " +
"\"Flat\" omits the project namespace and the \"resources\" directory. This is" +
" currently only supported for projects of type 'library'. Projects of " +
"type 'application' always have a default result as a flat output." +
"No other dependencies can be included in the build result.",
// We need to explicitly check wether the falsy value is explicit or not for project type "application"
// default: false,
type: "boolean"
type: "string",
default: "Default",
choices: ["Default", "Flat", "Namespace"],
})
.example("ui5 build", "Preload build for project without dependencies")
.example("ui5 build self-contained", "Self-contained build for project")
Expand Down Expand Up @@ -188,7 +188,7 @@ async function handleBuild(argv) {
includedTasks: argv["include-task"],
excludedTasks: argv["exclude-task"],
cssVariables: argv["experimental-css-variables"],
flatOutput: argv["flat-output"],
outputStyle: argv["output-style"],
});
}

Expand Down
9 changes: 5 additions & 4 deletions test/lib/cli/commands/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function getDefaultArgv() {
"experimentalCssVariables": false,
"cache-mode": "Default",
"cacheMode": "Default",
"output-style": "Default",
"$0": "ui5"
};
}
Expand All @@ -51,7 +52,7 @@ function getDefaultBuilderArgs() {
includedTasks: undefined,
excludedTasks: undefined,
cssVariables: false,
flatOutput: undefined
outputStyle: "Default"
};
}

Expand Down Expand Up @@ -366,14 +367,14 @@ test.serial("ui5 build --experimental-css-variables", async (t) => {
"Build with activated CSS Variables is called with expected arguments");
});

test.serial("ui5 build --flat-output", async (t) => {
test.serial("ui5 build --output-style", async (t) => {
const {build, argv, builder, expectedBuilderArgs} = t.context;

argv["flat-output"] = true;
argv["output-style"] = "Flat";

await build.handler(argv);

expectedBuilderArgs.flatOutput = true;
expectedBuilderArgs.outputStyle = "Flat";
t.deepEqual(builder.getCall(0).args[0], expectedBuilderArgs,
"Build with activated flatOutput is called with expected arguments");
});

0 comments on commit 936e6a7

Please sign in to comment.