-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(@angular/cli): ng e2e defaults to random port (#4753)
BREAKING CHANGE: `ng e2e` will use a random port for serving by default instead of using 4200.
- Loading branch information
1 parent
b6d8511
commit d2bef98
Showing
6 changed files
with
101 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 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,24 @@ | ||
import * as denodeify from 'denodeify'; | ||
|
||
const SilentError = require('silent-error'); | ||
const PortFinder = require('portfinder'); | ||
const getPort = <any>denodeify(PortFinder.getPort); | ||
|
||
PortFinder.basePort = 49152; | ||
|
||
|
||
export function checkPort(port: number, host: string) { | ||
return getPort({ port, host }) | ||
.then((foundPort: number) => { | ||
|
||
// If the port isn't available and we weren't looking for any port, throw error. | ||
if (port !== foundPort && port !== 0) { | ||
throw new SilentError( | ||
`Port ${port} is already in use. Use '--port' to specify a different port.` | ||
); | ||
} | ||
|
||
// Otherwise, our found port is good. | ||
return foundPort; | ||
}); | ||
} |
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,12 @@ | ||
const cloneDeep = require('lodash/cloneDeep'); | ||
|
||
export function overrideOptions(original: any[], overrides: any[]) { | ||
let copy = cloneDeep(original); | ||
overrides.forEach(override => { | ||
const option = copy.find((opt: any) => opt.name == override.name); | ||
if (option) { | ||
Object.assign(option, override); | ||
} | ||
}); | ||
return copy; | ||
} |
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