Files: 0b835dd3b9f970b3fdb54c75f7deb520f1552357 / nodejs-assets / nodejs-project / utils.js
373 bytesRaw
1 | const freeport = require('freeport'); |
2 | |
3 | /** |
4 | * @function findFreePort |
5 | * @description Returns a free port to start a server |
6 | * @return {Promise<Number>} A free port |
7 | */ |
8 | module.exports.findFreePort = () => |
9 | new Promise((resolve, reject) => { |
10 | return freeport((err, port) => { |
11 | if (err) { |
12 | return reject(err); |
13 | } |
14 | |
15 | return resolve(port); |
16 | }); |
17 | }); |
Built with git-ssb-web