mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 07:37:19 +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
|
@ -542,7 +542,6 @@ function execute(port) {
|
|||
});
|
||||
|
||||
app.listen(port);
|
||||
console.log('Open http://localhost:' + port + '/');
|
||||
}
|
||||
|
||||
module.exports = execute;
|
||||
|
|
|
@ -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) {
|
||||
|
|
15
package-lock.json
generated
15
package-lock.json
generated
|
@ -3381,6 +3381,12 @@
|
|||
"integrity": "sha1-Sw2hRCEE0bM2NA6AeX6GXPOffXI=",
|
||||
"dev": true
|
||||
},
|
||||
"is-wsl": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-1.1.0.tgz",
|
||||
"integrity": "sha1-HxbkqiKwTRM2tmGIpmrzxgDDpm0=",
|
||||
"dev": true
|
||||
},
|
||||
"is2": {
|
||||
"version": "0.0.9",
|
||||
"resolved": "https://registry.npmjs.org/is2/-/is2-0.0.9.tgz",
|
||||
|
@ -4634,6 +4640,15 @@
|
|||
"wrappy": "1.0.2"
|
||||
}
|
||||
},
|
||||
"opn": {
|
||||
"version": "5.3.0",
|
||||
"resolved": "https://registry.npmjs.org/opn/-/opn-5.3.0.tgz",
|
||||
"integrity": "sha512-bYJHo/LOmoTd+pfiYhfZDnf9zekVJrY+cnS2a5F2x+w5ppvTqObojTP7WiFG+kVZs9Inw+qQ/lw7TroWwhdd2g==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"is-wsl": "1.1.0"
|
||||
}
|
||||
},
|
||||
"optimist": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz",
|
||||
|
|
|
@ -70,6 +70,7 @@
|
|||
"front-matter": "^2.3.0",
|
||||
"glob-promise": "^3.3.0",
|
||||
"jest": "^21.2.1",
|
||||
"opn": "^5.3.0",
|
||||
"prettier": "^1.9.1",
|
||||
"rimraf": "^2.6.2"
|
||||
}
|
||||
|
|
10
yarn.lock
10
yarn.lock
|
@ -2049,6 +2049,10 @@ is-utf8@^0.2.0:
|
|||
version "0.2.1"
|
||||
resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72"
|
||||
|
||||
is-wsl@^1.1.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-1.1.0.tgz#1f16e4aa22b04d1336b66188a66af3c600c3a66d"
|
||||
|
||||
is2@0.0.9:
|
||||
version "0.0.9"
|
||||
resolved "https://registry.yarnpkg.com/is2/-/is2-0.0.9.tgz#119556d1d1651a41ba105af803267c80b299f629"
|
||||
|
@ -2852,6 +2856,12 @@ once@^1.3.0, once@^1.3.3, once@^1.4.0:
|
|||
dependencies:
|
||||
wrappy "1"
|
||||
|
||||
opn@^5.3.0:
|
||||
version "5.3.0"
|
||||
resolved "https://registry.yarnpkg.com/opn/-/opn-5.3.0.tgz#64871565c863875f052cfdf53d3e3cb5adb53b1c"
|
||||
dependencies:
|
||||
is-wsl "^1.1.0"
|
||||
|
||||
optimist@^0.6.1:
|
||||
version "0.6.1"
|
||||
resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue