mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 07:37:19 +02:00
Initial changes to error messages
This commit is contained in:
parent
e285f93c1b
commit
b256d2f8d9
7 changed files with 45 additions and 6 deletions
|
@ -16,5 +16,17 @@ require("babel-register")({
|
|||
presets: ["react", "latest"]
|
||||
});
|
||||
|
||||
// initial check that required files are present
|
||||
const chalk = require("chalk");
|
||||
const fs = require("fs");
|
||||
const CWD = process.cwd();
|
||||
|
||||
if (!fs.existsSync(CWD + "/siteConfig.js")) {
|
||||
console.error(
|
||||
chalk.red("Error: No siteConfig.js file found in website folder!")
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const generate = require("./server/generate.js");
|
||||
generate();
|
||||
|
|
|
@ -128,6 +128,12 @@ class HeaderNav extends React.Component {
|
|||
"-" +
|
||||
link.doc;
|
||||
}
|
||||
if (!Metadata[id]) {
|
||||
throw new Error(
|
||||
"A headerLink is specified with a document that does not exist. No document exists with id: " +
|
||||
link.doc
|
||||
);
|
||||
}
|
||||
href = this.props.config.baseUrl + Metadata[id].permalink;
|
||||
} else if (link.page) {
|
||||
if (fs.existsSync(CWD + "/pages/en/" + link.page + ".js")) {
|
||||
|
|
|
@ -56,7 +56,7 @@ function readCategories(sidebar) {
|
|||
if (metadata.next) {
|
||||
if (!articles[metadata.next]) {
|
||||
throw new Error(
|
||||
"`next: " + metadata.next + "` in " + metadata.id + " doesn't exist"
|
||||
"Improper sidebars.json file. Make sure that documents with the ids specified in sidebars.json exist and that no ids are repeated."
|
||||
);
|
||||
}
|
||||
previous[articles[metadata.next].id] = metadata.id;
|
||||
|
|
|
@ -32,7 +32,12 @@ if (fs.existsSync(CWD + "/languages.js")) {
|
|||
}
|
||||
|
||||
function readSidebar() {
|
||||
let allSidebars = require(CWD + "/sidebars.json");
|
||||
let allSidebars;
|
||||
if (fs.existsSync(CWD + "/sidebars.json")) {
|
||||
allSidebars = require(CWD + "/sidebars.json");
|
||||
} else {
|
||||
allSidebars = {};
|
||||
}
|
||||
Object.assign(allSidebars, versionFallback.sidebarData());
|
||||
|
||||
const order = {};
|
||||
|
|
|
@ -157,6 +157,10 @@ function execute(port) {
|
|||
});
|
||||
|
||||
const metadata = Metadata[links[url]];
|
||||
if (!metadata) {
|
||||
next();
|
||||
return;
|
||||
}
|
||||
const language = metadata.language;
|
||||
|
||||
let file;
|
||||
|
@ -438,7 +442,6 @@ function execute(port) {
|
|||
res.send(cssContent);
|
||||
});
|
||||
|
||||
/* serve static content first from user folder then from docusaurus */
|
||||
app.use(
|
||||
siteConfig.baseUrl + "docs/assets/",
|
||||
express.static(CWD + "/../docs/assets")
|
||||
|
|
|
@ -16,6 +16,18 @@ require("babel-register")({
|
|||
presets: ["react", "latest"]
|
||||
});
|
||||
|
||||
// initial check that required files are present
|
||||
const chalk = require("chalk");
|
||||
const fs = require("fs");
|
||||
const CWD = process.cwd();
|
||||
|
||||
if (!fs.existsSync(CWD + "/siteConfig.js")) {
|
||||
console.error(
|
||||
chalk.red("Error: No siteConfig.js file found in website folder!")
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const program = require("commander");
|
||||
|
||||
program.option("--port <number>", "Specify port number").parse(process.argv);
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
"babel-register": "^6.24.1",
|
||||
"babel-traverse": "^6.25.0",
|
||||
"babylon": "^6.17.4",
|
||||
"chalk": "^2.1.0",
|
||||
"classnames": "^2.2.5",
|
||||
"commander": "^2.11.0",
|
||||
"diff": "^3.3.0",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue