Skip to content

Commit

Permalink
[FIX] ui5.yaml: Use double quotes for string values (#660)
Browse files Browse the repository at this point in the history
Use `"` instead of `'` when writing yaml files.

UI5 Framework libraries use double quotes, so therefore aligning also UI5 Tooling init command.
  • Loading branch information
flovogt authored Oct 26, 2023
1 parent 08ed2a6 commit c30e371
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/cli/commands/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ initCommand.handler = async function() {
}

const projectConfig = await init();
const yaml = jsYaml.dump(projectConfig);
const yaml = jsYaml.dump(projectConfig, {quotingType: `"`});

await writeFile(yamlPath, yaml);
console.log(`Wrote ui5.yaml to ${yamlPath}:\n`);
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/init/application/ui5.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
specVersion: '0.1'
specVersion: "0.1"
metadata:
name: sample-app
type: application
6 changes: 4 additions & 2 deletions test/lib/cli/commands/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,21 @@ test.afterEach.always((t) => {
test.serial("Writes ui5.yaml to fs", async (t) => {
const ui5YamlPath = "./ui5.yaml";
const ui5Yaml = `
specVersion: '0.1'
specVersion: "0.1"
metadata:
name: sample-app
type: application`;

const fsWriteFileStub = sinon.stub().resolves();
const jsyamlDumpStub = sinon.stub().returns(ui5Yaml);

const initCommand = t.context.initCommand = await esmock.p("../../../../lib/cli/commands/init.js", {
"../../../../lib/utils/fsHelper": {
exists: sinon.stub().resolves(false)
},
"../../../../lib/init/init": sinon.stub().resolves({}),
"js-yaml": {
dump: sinon.stub().returns(ui5Yaml)
dump: jsyamlDumpStub
},
"node:path": {
resolve: () => ui5YamlPath
Expand All @@ -37,6 +38,7 @@ test.serial("Writes ui5.yaml to fs", async (t) => {

t.is(fsWriteFileStub.getCall(0).args[0], ui5YamlPath, "Passes yaml path to write the yaml file to");
t.is(fsWriteFileStub.getCall(0).args[1], ui5Yaml, "Passes yaml content to write to fs");
t.deepEqual(jsyamlDumpStub.getCall(0).args[1], {quotingType: `"`}, "Enforce usage of double quotes in yaml files");
});

test.serial("Error: throws if ui5.yaml already exists", async (t) => {
Expand Down

0 comments on commit c30e371

Please sign in to comment.