diff --git a/cli.js b/cli.js index 5389b14..f5126ca 100644 --- a/cli.js +++ b/cli.js @@ -44,15 +44,16 @@ const executeForPath = async(arg, options) => { const unusedVars = await fusv.findAsync(dir, options); console.log(`\nSearching for unused variables in "${picocolors.cyan(dir)}" folder, ${picocolors.cyan(options.fileExtensions.join(', '))} files...`); - console.log(`${picocolors.cyan(unusedVars.total)} total variables.`); + console.log(`${picocolors.cyan(unusedVars.total)} total variable${unusedVars.total > 1 ? 's' : ''}.`); - if (unusedVars.unused.length > 0) { - console.log(`${picocolors.yellow(unusedVars.unused.length)} are not used!`); + const unusedVarsNumber = unusedVars.unused.length; + if (unusedVarsNumber > 0) { + console.log(`${picocolors.yellow(unusedVarsNumber)} ${unusedVarsNumber > 1 ? 'are' : 'is'} not used!`); for (const { name, file, line } of unusedVars.unused) { console.log(`Variable ${picocolors.red(name)} is not being used! ${picocolors.gray(file)}:${picocolors.yellow(line)}`); } - throw new Error(`Found ${unusedVars.unused.length} unused variables in "${picocolors.cyan(dir)}" folder`); + throw new Error(`Found ${unusedVarsNumber} unused variable${unusedVarsNumber > 1 ? 's' : ''} in "${picocolors.cyan(dir)}" folder`); } console.log(picocolors.green(`No unused variables found in "${dir}!"`));