Skip to content

Commit 27383de

Browse files
committed
Tweak callback throw error
1 parent 36833e8 commit 27383de

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

lib/detect-port.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ module.exports = function() {
77

88
const promise = new Promise((resolve, reject) => {
99
if (!args.length) {
10-
reject('wrong number of arguments');
10+
return reject('wrong number of arguments');
1111
}
1212

1313
const port = parseInt(args[0], 10);
1414

1515
if (isNaN(port)) {
16-
reject(`wrong type of arguments with: '${args[0]}'`);
16+
return reject(`wrong type of arguments with: '${args[0]}'`);
1717
}
1818

1919
const loop = port => {
@@ -63,9 +63,9 @@ module.exports = function() {
6363
const cb = args[1];
6464

6565
promise.then(data => {
66-
cb.call(this, null, data);
67-
}).catch(err => {
68-
cb.call(this, err);
66+
process.nextTick(cb.bind(null, null, data));
67+
}, err => {
68+
process.nextTick(cb.bind(null, err));
6969
});
7070
} else {
7171
return promise;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "detect-port",
3-
"version": "1.0.6",
3+
"version": "1.0.7",
44
"description": "detect available port",
55
"keywords": [
66
"detect",

0 commit comments

Comments
 (0)