mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-28 08:27:03 +02:00
Add open in browser functionality (#643)
This commit is contained in:
parent
432bdffb22
commit
1a6f2fc51c
5 changed files with 30 additions and 2 deletions
|
@ -24,6 +24,7 @@ const tcpPortUsed = require('tcp-port-used');
|
|||
// initial check that required files are present
|
||||
const chalk = require('chalk');
|
||||
const fs = require('fs');
|
||||
const opn = require('opn');
|
||||
const CWD = process.cwd();
|
||||
|
||||
if (!fs.existsSync(CWD + '/siteConfig.js')) {
|
||||
|
@ -59,10 +60,12 @@ function checkPort() {
|
|||
numAttempts += 1;
|
||||
checkPort();
|
||||
} else {
|
||||
console.log('Starting Docusaurus server on port ' + port + '...');
|
||||
// start local server on specified port
|
||||
const server = require('./server/server.js');
|
||||
server(port);
|
||||
const host = `http://localhost:${port}`;
|
||||
console.log(`Starting Docusaurus server on ${host}`);
|
||||
opn(host);
|
||||
}
|
||||
})
|
||||
.catch(function(ex) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue