Skip to content

Commit

Permalink
Improve CLI (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
XhmikosR authored Mar 18, 2022
1 parent 44464ab commit c73119b
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,20 @@ const precinct = require('../index.js');
const { version } = require('../package.json');

program
.arguments('<filename>')
.version(version)
.usage('[options] <filename>')
.option('--es6-mixedImports')
.option('-t, --type <type>', 'The type of content being passed in. Useful if you want to use a non-js detective')
.parse(process.argv);

const content = fs.readFileSync(program.args[0], 'utf8');
.option('--es6-mixedImports', 'Fetch all dependendies from a file that contains both CJS and ES6 imports')
.option('-t, --type <type>', 'The type of content being passed in. Useful if you want to use a non-JS detective')
.parse();

const cliOptions = program.opts();
const options = {
es6: {}
es6: {
mixedImports: Boolean(cliOptions.es6MixedImports)
},
type: cliOptions.type
};

const cliOptions = program.opts();

if (cliOptions.es6MixedImports) {
options.es6.mixedImports = true;
}

if (cliOptions.type) {
options.type = cliOptions.type;
}
const content = fs.readFileSync(program.args[0], 'utf8');

console.log(precinct(content, options).join('\n'));

0 comments on commit c73119b

Please sign in to comment.