aboutsummaryrefslogtreecommitdiff
path: root/node_modules/get-port
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/get-port')
-rw-r--r--node_modules/get-port/index.js16
-rw-r--r--node_modules/get-port/license20
-rw-r--r--node_modules/get-port/package.json3
-rw-r--r--node_modules/get-port/readme.md27
4 files changed, 43 insertions, 23 deletions
diff --git a/node_modules/get-port/index.js b/node_modules/get-port/index.js
index de99a3662..fbd74e6e6 100644
--- a/node_modules/get-port/index.js
+++ b/node_modules/get-port/index.js
@@ -1,13 +1,21 @@
'use strict';
const net = require('net');
-const getPort = port => new Promise((resolve, reject) => {
+const getPort = options => new Promise((resolve, reject) => {
+ // For backwards compatibility with number-only input
+ // TODO: Remove this in the next major version
+ if (typeof options === 'number') {
+ options = {
+ port: options
+ };
+ }
+
const server = net.createServer();
server.unref();
server.on('error', reject);
- server.listen(port, () => {
+ server.listen(options, () => {
const port = server.address().port;
server.close(() => {
resolve(port);
@@ -15,6 +23,6 @@ const getPort = port => new Promise((resolve, reject) => {
});
});
-module.exports = preferredPort => preferredPort ?
- getPort(preferredPort).catch(() => getPort(0)) :
+module.exports = options => options ?
+ getPort(options).catch(() => getPort(0)) :
getPort(0);
diff --git a/node_modules/get-port/license b/node_modules/get-port/license
index 654d0bfe9..e7af2f771 100644
--- a/node_modules/get-port/license
+++ b/node_modules/get-port/license
@@ -1,21 +1,9 @@
-The MIT License (MIT)
+MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/get-port/package.json b/node_modules/get-port/package.json
index 235a2b1c6..3fe192258 100644
--- a/node_modules/get-port/package.json
+++ b/node_modules/get-port/package.json
@@ -1,6 +1,6 @@
{
"name": "get-port",
- "version": "3.1.0",
+ "version": "3.2.0",
"description": "Get an available port",
"license": "MIT",
"repository": "sindresorhus/get-port",
@@ -38,6 +38,7 @@
],
"devDependencies": {
"ava": "*",
+ "pify": "^3.0.0",
"xo": "*"
}
}
diff --git a/node_modules/get-port/readme.md b/node_modules/get-port/readme.md
index 292b8c3d7..72c1fbc01 100644
--- a/node_modules/get-port/readme.md
+++ b/node_modules/get-port/readme.md
@@ -6,7 +6,7 @@
## Install
```
-$ npm install --save get-port
+$ npm install get-port
```
@@ -24,13 +24,36 @@ getPort().then(port => {
Optionally, pass in a preferred port:
```js
-getPort(3000).then(port => {
+getPort({port: 3000}).then(port => {
console.log(port);
// Will use 3000 if available, otherwise fall back to a random port
});
```
+## API
+
+### getPort([options])
+
+Returns a `Promise` for a port number.
+
+#### options
+
+Type: `Object`
+
+##### port
+
+Type: `number`
+
+The preferred port to use.
+
+##### host
+
+Type: `string`
+
+The host on which port resolution should be performed. Can be either an IPv4 or IPv6 address.
+
+
## Related
- [get-port-cli](https://github.com/sindresorhus/get-port-cli) - CLI for this module