Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Application: Fallback to manifest.appdescr_variant if manifest.json is not found #631

Merged
merged 2 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/specifications/types/Application.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading