-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(lib/utils): move
createLog
&& rename files (#1465)
- Loading branch information
1 parent
0e1f0c1
commit 2ee13ab
Showing
9 changed files
with
95 additions
and
66 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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,35 @@ | ||
'use strict'; | ||
|
||
/* eslint-disable | ||
no-nested-ternary, | ||
multiline-ternary, | ||
space-before-function-paren | ||
*/ | ||
const url = require('url'); | ||
const ip = require('internal-ip'); | ||
|
||
function createDomain (options, server) { | ||
const protocol = options.https ? 'https' : 'http'; | ||
const hostname = options.useLocalIp ? ip.v4() : options.host; | ||
|
||
const port = options.socket | ||
? 0 | ||
: server | ||
? server.address().port | ||
: 0; | ||
// use explicitly defined public url | ||
// (prefix with protocol if not explicitly given) | ||
if (options.public) { | ||
return /^[a-zA-Z]+:\/\//.test(options.public) | ||
? `${options.public}` | ||
: `${protocol}://${options.public}`; | ||
} | ||
// the formatted domain (url without path) of the webpack server | ||
return url.format({ | ||
protocol, | ||
hostname, | ||
port | ||
}); | ||
} | ||
|
||
module.exports = createDomain; |
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,26 @@ | ||
'use strict'; | ||
|
||
/* eslint-disable | ||
space-before-function-paren | ||
*/ | ||
const log = require('webpack-log'); | ||
|
||
function createLogger (options) { | ||
let level = options.logLevel || 'info'; | ||
|
||
if (options.quiet === true) { | ||
level = 'silent'; | ||
} | ||
|
||
if (options.noInfo === true) { | ||
level = 'warn'; | ||
} | ||
|
||
return log({ | ||
name: 'wds', | ||
level, | ||
timestamp: options.logTime | ||
}); | ||
} | ||
|
||
module.exports = createLogger; |
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