docusaurus/lib/start-server.js

38 lines
925 B
JavaScript
Raw Normal View History

2017-07-07 13:28:29 -04:00
#!/usr/bin/env node
/**
* Copyright (c) 2017-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
2017-07-07 13:28:29 -04:00
*/
2017-07-10 19:38:35 -04:00
require("babel-register")({
babelrc: false,
only: [__dirname, process.cwd() + "/core"],
plugins: [require("./server/translate-plugin.js")],
presets: ["react", "env"]
2017-07-07 13:28:29 -04:00
});
2017-08-09 18:43:30 -04:00
// 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);
2017-08-09 18:43:30 -04:00
}
2017-07-13 16:40:24 -04:00
const program = require("commander");
program.option("--port <number>", "Specify port number").parse(process.argv);
const port = program.port || 3000;
2017-08-15 19:55:38 -04:00
// start local server on specified port
2017-07-10 19:38:35 -04:00
const server = require("./server/server.js");
server(port);