Skip to content

Commit

Permalink
Require Node.js 6
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Jul 24, 2018
1 parent f5c9753 commit 405abaf
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 57 deletions.
3 changes: 1 addition & 2 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
* text=auto
*.js text eol=lf
* text=auto eol=lf
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: node_js
node_js:
- '10'
- '8'
- '6'
- '4'
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const isAvailable = options => new Promise((resolve, reject) => {
});
});

const getPort = options => 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') {
Expand Down
83 changes: 41 additions & 42 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,44 +1,43 @@
{
"name": "get-port",
"version": "3.2.0",
"description": "Get an available port",
"license": "MIT",
"repository": "sindresorhus/get-port",
"author": {
"name": "Sindre Sorhus",
"email": "[email protected]",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=4"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"port",
"find",
"finder",
"portfinder",
"free",
"available",
"connection",
"connect",
"open",
"net",
"tcp",
"scan",
"rand",
"random",
"preferred",
"chosen"
],
"devDependencies": {
"ava": "*",
"pify": "^3.0.0",
"xo": "*"
}
"name": "get-port",
"version": "3.2.0",
"description": "Get an available port",
"license": "MIT",
"repository": "sindresorhus/get-port",
"author": {
"name": "Sindre Sorhus",
"email": "[email protected]",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=6"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"port",
"find",
"finder",
"portfinder",
"free",
"available",
"connection",
"connect",
"open",
"net",
"tcp",
"scan",
"random",
"preferred",
"chosen"
],
"devDependencies": {
"ava": "*",
"pify": "^3.0.0",
"xo": "*"
}
}
22 changes: 11 additions & 11 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,28 @@ $ npm install get-port
```js
const getPort = require('get-port');

getPort().then(port => {
console.log(port);
(async () => {
console.log(await getPort());
//=> 51402
});
})();
```

To pass in a preferred port:
Pass in a preferred port:

```js
getPort({port: 3000}).then(port => {
console.log(port);
(async () => {
console.log(await getPort({port: 3000}));
// Will use 3000 if available, otherwise fall back to a random port
});
})();
```

To pass in an array of preferred ports:
Pass in an array of preferred ports:

```js
getPort({port: [3000, 3001, 3002]}).then(port => {
console.log(port);
(async () => {
console.log(await getPort({port: [3000, 3001, 3002]}));
// Will use any element in the preferred ports array if available, otherwise fall back to a random port
});
})();
```

## API
Expand Down

0 comments on commit 405abaf

Please sign in to comment.