desirae.js/lib/verify-config.js

63 行
1.5 KiB
JavaScript

2020-11-09 03:01:26 +00:00
(function (exports) {
"use strict";
2015-01-05 19:23:26 +00:00
2015-01-06 06:52:44 +00:00
exports.verifyConfig = function (conf) {
if (!conf.NuhohSpec) {
throw new Error("missing key NuhohSpec");
}
2015-01-05 19:23:26 +00:00
2015-01-06 06:52:44 +00:00
if (!conf.production) {
throw new Error("missing key production");
}
2015-01-05 19:23:26 +00:00
2015-01-06 06:52:44 +00:00
if (!conf.production.canonical_url) {
throw new Error("missing key production.canonical_url");
}
2015-01-05 19:23:26 +00:00
2015-01-06 06:52:44 +00:00
if (!conf.production.base_path) {
throw new Error("missing key production.base_path");
}
2015-01-05 19:23:26 +00:00
2015-01-06 06:52:44 +00:00
if (!conf.development) {
throw new Error("missing key development");
}
2015-01-05 19:23:26 +00:00
2015-01-06 06:52:44 +00:00
if (!conf.development.compiled_path) {
throw new Error("missing key development.compiled_path");
}
2015-01-05 19:23:26 +00:00
2015-01-06 06:52:44 +00:00
if (!Array.isArray(conf.collections)) {
if (conf.posts) {
2020-11-09 03:01:26 +00:00
console.error(
"Please indent and nest 'posts' under the key 'collection' to continue"
);
2015-01-06 06:52:44 +00:00
}
throw new Error("missing key 'collections'.");
2015-01-05 19:23:26 +00:00
}
2015-01-06 06:52:44 +00:00
if (!conf.themes) {
if (conf.twitter) {
2020-11-09 03:01:26 +00:00
console.error(
"Please indent and nest 'twitter' under the key 'themes' to continue"
);
2015-01-06 06:52:44 +00:00
}
throw new Error("missing key 'themes'");
2015-01-05 19:23:26 +00:00
}
2015-01-06 06:52:44 +00:00
if (!conf.themes.default) {
if (conf.twitter) {
console.error("Please set themes.default to 'twitter'");
}
throw new Error("missing key 'themes.default'");
2015-01-05 19:23:26 +00:00
}
2015-01-06 06:52:44 +00:00
if (!conf.root) {
throw new Error("missing key root");
}
2015-01-05 19:23:26 +00:00
2015-01-06 06:52:44 +00:00
if (!conf.widgets) {
throw new Error("missing key root");
}
};
2020-11-09 03:01:26 +00:00
})(("undefined" !== typeof exports && exports) || window);