portfinder
Advanced tools
+21
| language: node_js | ||
| node_js: | ||
| - "0.8" | ||
| - "0.10" | ||
| - "0.11" | ||
| before_install: | ||
| - travis_retry npm install -g npm | ||
| - travis_retry npm install | ||
| script: | ||
| - npm test | ||
| matrix: | ||
| allow_failures: | ||
| - node_js: "0.11" | ||
| notifications: | ||
| email: | ||
| - travis@nodejitsu.com | ||
| irc: "irc.freenode.org#nodejitsu" |
| /* | ||
| * portfinder-test.js: Tests for the `portfinder` module. | ||
| * | ||
| * (C) 2011, Charlie Robbins | ||
| * | ||
| */ | ||
| var vows = require('vows'), | ||
| assert = require('assert'), | ||
| async = require('async'), | ||
| http = require('http'), | ||
| portfinder = require('../lib/portfinder'); | ||
| var servers = []; | ||
| function createServers (callback) { | ||
| var base = 8000; | ||
| async.whilst( | ||
| function () { return base < 8005 }, | ||
| function (next) { | ||
| var server = http.createServer(function () { }); | ||
| server.listen(base, next); | ||
| base++; | ||
| servers.push(server); | ||
| }, callback); | ||
| } | ||
| vows.describe('portfinder').addBatch({ | ||
| "When using portfinder module": { | ||
| "with 5 existing servers": { | ||
| topic: function () { | ||
| createServers(this.callback); | ||
| }, | ||
| "the getPorts() method with an argument of 3": { | ||
| topic: function () { | ||
| portfinder.getPorts(3, this.callback); | ||
| }, | ||
| "should respond with the first three available ports (8005, 8006, 8007)": function (err, ports) { | ||
| assert.isTrue(!err); | ||
| assert.deepEqual(ports, [8005, 8006, 8007]); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }).addBatch({ | ||
| "When using portfinder module": { | ||
| "with no existing servers": { | ||
| topic: function () { | ||
| servers.forEach(function (server) { | ||
| server.close(); | ||
| }); | ||
| return null; | ||
| }, | ||
| "the getPorts() method with an argument of 3": { | ||
| topic: function () { | ||
| portfinder.getPorts(3, this.callback); | ||
| }, | ||
| "should respond with the first three available ports (8000, 8001, 80072": function (err, ports) { | ||
| assert.isTrue(!err); | ||
| assert.deepEqual(ports, [8000, 8001, 8002]); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }).export(module); |
+31
-0
@@ -11,2 +11,3 @@ /* | ||
| path = require('path'), | ||
| async = require('async'), | ||
| mkdirp = require('mkdirp').mkdirp; | ||
@@ -72,2 +73,32 @@ | ||
| // | ||
| // ### function getPorts (count, options, callback) | ||
| // #### @count {Number} The number of ports to find | ||
| // #### @options {Object} Settings to use when finding the necessary port | ||
| // #### @callback {function} Continuation to respond to when complete. | ||
| // Responds with an array of unbound ports on the current machine. | ||
| // | ||
| exports.getPorts = function (count, options, callback) { | ||
| if (!callback) { | ||
| callback = options; | ||
| options = {}; | ||
| } | ||
| var lastPort = null; | ||
| async.timesSeries(count, function(index, asyncCallback) { | ||
| if (lastPort) { | ||
| options.port = exports.nextPort(lastPort); | ||
| } | ||
| exports.getPort(options, function (err, port) { | ||
| if (err) { | ||
| asyncCallback(err); | ||
| } else { | ||
| lastPort = port; | ||
| asyncCallback(null, port); | ||
| } | ||
| }); | ||
| }, callback); | ||
| }; | ||
| // | ||
| // ### function getSocket (options, callback) | ||
@@ -74,0 +105,0 @@ // #### @options {Object} Settings to use when finding the necessary port |
+5
-5
| { | ||
| "name": "portfinder", | ||
| "version": "0.3.0", | ||
| "version": "0.4.0", | ||
| "description": "A simple tool to find an open port on the current machine", | ||
@@ -12,12 +12,12 @@ "author": "Charlie Robbins <charlie.robbins@gmail.com>", | ||
| "dependencies": { | ||
| "mkdirp": "0.0.x" | ||
| "async": "0.9.0", | ||
| "mkdirp": "0.5.x" | ||
| }, | ||
| "devDependencies": { | ||
| "async": "0.1.x", | ||
| "vows": "0.5.x" | ||
| "vows": "0.8.0" | ||
| }, | ||
| "main": "./lib/portfinder", | ||
| "scripts": { "test": "vows test/*-test.js --spec" }, | ||
| "engines": { "node": ">= 0.4.0" }, | ||
| "engines": { "node": ">= 0.8.0" }, | ||
| "license": "MIT/X11" | ||
| } |
+4
-4
@@ -1,2 +0,2 @@ | ||
| # node-portfinder | ||
| # node-portfinder [](https://travis-ci.org/indexzero/node-portfinder) | ||
@@ -20,6 +20,6 @@ ## Installation | ||
| var portfinder = require('portfinder'); | ||
| portfinder.getPort(function (err, port) { | ||
| // | ||
| // `port` is guarenteed to be a free port | ||
| // `port` is guaranteed to be a free port | ||
| // in this scope. | ||
@@ -39,2 +39,2 @@ // | ||
| #### License: MIT/X11 | ||
| [0]: http://nodejitsu.com | ||
| [0]: http://nodejitsu.com |
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 2 instances in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
14313
26.4%1
-50%10
25%397
28.48%39
2.63%2
100%5
25%+ Added
+ Added
+ Added
+ Added
- Removed
Updated