Skip to content

Instantly share code, notes, and snippets.

@marverix
Created August 27, 2018 13:56
Show Gist options
  • Save marverix/79c44a18f9f86fc4685ed1d6b59cd6f5 to your computer and use it in GitHub Desktop.
Save marverix/79c44a18f9f86fc4685ed1d6b59cd6f5 to your computer and use it in GitHub Desktop.
Node.js - Sync check if local port is available (linux only!)
const { execSync } = require('child_process');
module.exports = function(port) {
try {
execSync('nc -z 127.0.0.1 ' + port);
} catch(e) {
return true;
}
return false;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment