Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
geo-sot committed Mar 8, 2021
1 parent 9d10a52 commit b8c67a9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
19 changes: 10 additions & 9 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
program
.usage('[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/ tests2/ -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

0 comments on commit b8c67a9

Please sign in to comment.