Skip to content

Commit

Permalink
Force specs using ReSpec to use "unofficial" template.
Browse files Browse the repository at this point in the history
References w3c/respec#1334.
  • Loading branch information
tobie committed Jul 26, 2017
1 parent 4504aab commit b1f8738
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/models/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Config {
constructor(pr) {
this.pr = pr;
}

request() {
return this.pr.request(GH_API.GET_CONFIG_FILE).then(file => {
if (file.type != "file") {
Expand All @@ -17,7 +17,7 @@ class Config {
var json = JSON.parse(new Buffer(file.content, "base64").toString("utf8"));
Config.validate(json);
console.log("Found repo config file", json);
return json;
return Config.override(json);
});
}
}
Expand All @@ -26,4 +26,12 @@ module.exports = Config;
module.exports.validate = function(config) {
let result = validator.validateResult(config, schema);
if (!result.valid) throw result.error;
};
};

module.exports.override = function(config) {
if (config.type.toLowerCase() == "respec") {
config.params = config.params || {};
config.params.specStatus = "unofficial";
}
return config;
};
13 changes: 13 additions & 0 deletions test/models/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,16 @@ suite("Config validation", function() {
});
});

suite("Config.override", function() {
test("Bikeshed config left untouched", function() {
assert.deepEqual({ type: "bikeshed" }, Config.override({ type: "bikeshed" }));
});

test("Force specStatus param for Respec", function() {
assert.deepEqual({
type: "respec",
params: { specStatus: "unofficial" }
}, Config.override({ type: "respec" }));
});
});

0 comments on commit b1f8738

Please sign in to comment.