-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Christoffer Åström
committed
Oct 30, 2017
1 parent
013b4ee
commit 940f0fd
Showing
6 changed files
with
51 additions
and
33 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
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,18 @@ | ||
const path = require('path'); | ||
const Koa = require('koa'); | ||
const serve = require('koa-static'); | ||
const favicon = require('koa-favicon'); | ||
const instrument = require('./instrument'); | ||
|
||
const app = new Koa(); | ||
|
||
module.exports = function server(url, files, coverage, nyc, options) { | ||
if (/^(http(s?)):\/\//.test(url)) { | ||
app.use(favicon(path.resolve(__dirname, '../../aw.png'))); | ||
if (coverage) { | ||
app.use(instrument(files, nyc)); | ||
} | ||
app.use(...options.root.map(root => serve(path.resolve(process.cwd(), root)))); | ||
app.listen(options.port); | ||
} | ||
}; |