Skip to content

Commit

Permalink
[FIX] Application: Fallback to manifest.appdescr_variant if manifest.…
Browse files Browse the repository at this point in the history
…json is not found (#631)

This fixes a regression presumably present since ui5-project v3.0.0,
which prevented proper fallback to manifest.appdescr_variant in case no
manifest.json is found in the project.
  • Loading branch information
RandomByte committed Jul 13, 2023
1 parent 557cb36 commit 43c6b22
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion lib/specifications/types/Application.js
Expand Up @@ -214,11 +214,16 @@ class Application extends ComponentProject {
return this._pManifests[filePath] = this._getRawSourceReader().byPath(filePath)
.then(async (resource) => {
if (!resource) {
throw new Error(
const error = new Error(
`Could not find resource ${filePath} in project ${this.getName()}`);
error.code = "ENOENT"; // "File or directory does not exist"
throw error;
}
return JSON.parse(await resource.getString());
}).catch((err) => {
if (err.code === "ENOENT") {
throw err;
}
throw new Error(
`Failed to read ${filePath} for project ` +
`${this.getName()}: ${err.message}`);
Expand Down
4 changes: 2 additions & 2 deletions test/lib/specifications/types/Application.js
Expand Up @@ -583,10 +583,10 @@ test.serial("_getManifest: File does not exist", async (t) => {
const project = await Specification.create(projectInput);

const error = await t.throwsAsync(project._getManifest("/does-not-exist.json"));
t.deepEqual(error.message,
"Failed to read /does-not-exist.json for project application.a: " +
t.is(error.message,
"Could not find resource /does-not-exist.json in project application.a",
"Rejected with correct error message");
t.is(error.code, "ENOENT");
});

test.serial("_getManifest: result is cached", async (t) => {
Expand Down

0 comments on commit 43c6b22

Please sign in to comment.