Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update commander to the latest version #138

Merged
merged 1 commit into from
Mar 8, 2021
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
21 changes: 11 additions & 10 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,26 @@
'use strict';

const path = require('path');
const commander = require('commander');
const { program } = require('commander');
const chalk = require('chalk');
const { version } = require('./package.json');
const fusv = require('.');

commander
.usage('[options] <folders...>')
program
.arguments('[options] <folders...>')
.version(version, '-v, --version')
.option('-i, --ignore <ignoredVars>', 'ignore variables, comma separated')
.option('-i, --ignore <ignoredVars>', 'ignore variables, comma separated', '')
.parse(process.argv);

function main(args) {
const ignore = commander.ignore ? commander.ignore.split(',') : [];
function main() {
const directories = program.args;
const ignore = program.opts().ignore.split(',');

console.log('Looking for unused variables');

let unusedList = [];

const results = Promise.all(args.map(path => executeForPath(path, ignore)));
const results = Promise.all(directories.map(path => executeForPath(path, ignore)));

results.catch(error => {
console.log(chalk.redBright(error.message));
Expand Down Expand Up @@ -70,10 +71,10 @@ const executeForPath = (arg, ignore) => {
});
};

const args = commander.args.filter(arg => typeof arg === 'string');
const args = program.args.filter(arg => typeof arg === 'string');

if (args.length > 0) {
main(args);
main();
} else {
commander.help();
program.help();
}
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"lint": "npm run xo",
"test": "npm run xo && npm run test:integration",
"test:integration": "node tests/integration.js",
"check": "node ./cli.js tests/ non-existent-folder/ -i \"$a\"",
"xo": "xo"
},
"repository": {
Expand All @@ -29,7 +30,7 @@
"homepage": "https://github.com/XhmikosR/find-unused-sass-variables#readme",
"dependencies": {
"chalk": "^4.1.0",
"commander": "^5.1.0",
"commander": "^7.1.0",
"escape-string-regexp": "^4.0.0",
"glob": "^7.1.6",
"postcss": "^8.2.6",
Expand Down