Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions bin/detect-port
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const pkg = require('../package');
const args = process.argv.slice(2);
const arg_0 = args[0];

if (!!~['-v', '--version'].indexOf(arg_0)) {
if (arg_0 && !!~['-v', '--version'].indexOf(arg_0.toLowerCase())) {
console.log(pkg.version);
process.exit(0);
}
Expand Down Expand Up @@ -35,22 +35,30 @@ if (!arg_0) {
console.log();
console.log(' Options:');
console.log();
console.log(' -v, --version show version and exit');
console.log(' -v, --version output version and exit');
console.log(' -s, --silent output port without verbose log');
console.log(' -h, --help output usage information');
console.log();
console.log(' Further help:');
console.log();
console.log(` ${pkg.homepage}`);
console.log();
} else {
const isSilent = !!~process.argv.indexOf('-s') || !!~process.argv.indexOf('--silent');

main(port, (err, _port) => {
if (err) {
console.log(`get available port failed with ${err}`);
}
if (isSilent) {
console.log(_port || port);
} else {
if (err) {
console.log(`get available port failed with ${err}`);
}

if (port !== _port) {
console.log(`port ${port} was occupied`);
}

if (port !== _port) {
console.log(`port ${port} was occupied`);
console.log(`get available port ${_port}`);
}
console.log(`get available port ${_port}`);
});
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "detect-port",
"version": "1.1.3",
"version": "1.1.4",
"description": "detect available port",
"keywords": [
"detect",
Expand Down