portfinder/test/getPort.js
raw| 1 | const portfinder = require('../lib/portfinder'); |
| 2 | |
| 3 | if (process.argv[2]) { |
| 4 | const port = process.argv[2]; |
| 5 | if (isNaN(port)) { |
| 6 | console.log('passed value is not a port'); |
| 7 | } else { |
| 8 | portfinder.basePort = port; |
| 9 | } |
| 10 | } |
| 11 | |
| 12 | portfinder.getPort(function(err, port) { |
| 13 | if (err) { |
| 14 | console.error(err); |
| 15 | } else { |
| 16 | console.log(port); |
| 17 | } |
| 18 | }); |