This repository has been archived by the owner on Sep 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(site): Fix playroom routing in ghpages (#585)
- Loading branch information
1 parent
82fdd5c
commit fef3e43
Showing
3 changed files
with
61 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const { promisify } = require('util'); | ||
const mv = promisify(require('mv')); | ||
const opn = require('opn'); | ||
const fs = require('fs'); | ||
const { createServer } = require('http-server'); | ||
const portfinder = require('portfinder'); | ||
portfinder.basePort = 4000; | ||
|
||
(async() => { | ||
if (!fs.existsSync('docs/dist/seek-style-guide')) { // eslint-disable-line no-sync | ||
await mv('docs/dist', 'docs/seek-style-guide', { mkdirp: true }); | ||
await mv('docs/seek-style-guide', 'docs/dist/seek-style-guide', { mkdirp: true }); | ||
} | ||
|
||
const port = await portfinder.getPortPromise(); | ||
const host = '127.0.0.1'; | ||
const url = `http://${host}:${port}/seek-style-guide/`; | ||
|
||
createServer({ root: 'docs/dist', cache: -1 }) | ||
.listen(port, host, err => { | ||
if (err) { | ||
throw new Error(err); | ||
} | ||
|
||
console.log(`Preview available at: ${url}`); | ||
opn(url); | ||
}); | ||
})(); |