Skip to content

Commit

Permalink
Ensure that screensavers have default requirements defined
Browse files Browse the repository at this point in the history
  • Loading branch information
muffinista committed May 19, 2020
1 parent f1d2065 commit 444dff2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/lib/saver-list.js
Expand Up @@ -262,6 +262,10 @@ module.exports = class SaverListManager {
contents.published = true;
}

if ( typeof(contents.requirements) === "undefined" ) {
contents.requirements = ["screen"];
}

contents.valid = typeof(contents.name) !== "undefined" &&
typeof(contents.description) !== "undefined" &&
contents.published === true;
Expand Down
2 changes: 1 addition & 1 deletion src/main/index.js
Expand Up @@ -635,7 +635,7 @@ var runScreenSaverOnDisplay = function(saver, s) {
// otherwise just boot it
//
const reqs = saver.requirements;
if ( reqs.findIndex((x) => { return x === "screen"; }) > -1 ) {
if ( reqs !== undefined && reqs.findIndex((x) => { return x === "screen"; }) > -1 ) {
return grabScreen(s).then((message) => {
runSaver(message.url, saver, s, url_opts, tickCount);
});
Expand Down
8 changes: 8 additions & 0 deletions test/lib/saver-list.js
Expand Up @@ -111,6 +111,14 @@ describe("SaverListManager", function() {
done();
});
});

it("adds requirements if missing", (done) => {
var f = path.join(__dirname, "../fixtures/no-requirements.json");
savers.loadFromFile(f, false, {}).then((s) => {
assert.deepEqual(["screen"], s.requirements);
done();
});
});
});

describe("list", function() {
Expand Down

0 comments on commit 444dff2

Please sign in to comment.