diff --git a/cli.js b/cli.js index c9f3954..4f98a7a 100755 --- a/cli.js +++ b/cli.js @@ -21,24 +21,24 @@ if ( argv.indexOf('-v') !== -1 ) { console.log(pack.version); -} else if (argv.length) { - getSyllables(argv.join(' ')); -} else { +} else if (argv.length === 0) { process.stdin.resume(); process.stdin.setEncoding('utf8'); process.stdin.on('data', function (data) { getSyllables(data); }); +} else { + getSyllables(argv.join(' ')); } function getSyllables(value) { value = value.split(/\s+/g).map(trim).filter(Boolean); - if (value.length) { - console.log(syllables(value)); - } else { + if (value.length === 0) { process.stderr.write(help()); process.exit(1); + } else { + console.log(syllables(value)); } } diff --git a/index.js b/index.js index 96c1320..1c07f65 100644 --- a/index.js +++ b/index.js @@ -325,7 +325,7 @@ function syllable(value) { var addOne; var subtractOne; - if (!value.length) { + if (value.length === 0) { return count; } diff --git a/package.json b/package.json index 1b3643c..5a18ea1 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,6 @@ "space": true, "esnext": false, "rules": { - "unicorn/explicit-length-check": "off", "guard-for-in": "off" }, "ignores": [