Skip to content

Commit

Permalink
feat(cli): add option to compressor
Browse files Browse the repository at this point in the history
  • Loading branch information
srod committed Aug 10, 2018
1 parent 335084d commit 599395a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion __tests__/cli-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ describe('cli', function() {
cli({
compressor: 'gcc',
input: 'examples/public/js/sample.js',
output: 'examples/public/js-dist/babili-es6.js'
output: 'examples/public/js-dist/babili-es6.js',
option: '{"createSourceMap": true}'
});
expect(spy).toHaveBeenCalled();
});
Expand Down
3 changes: 2 additions & 1 deletion bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ program
.version(pkg.version, '-v, --version')
.option('-c, --compressor [compressor]', 'use the specified compressor [uglifyjs]', 'uglifyjs')
.option('-i, --input [file]', 'input file path')
.option('-o, --output [file]', 'output file path');
.option('-o, --output [file]', 'output file path')
.option('-O, --option [option]', 'option for the compressor as JSON object', '');

program.on('--help', function() {
console.log(' List of compressors:');
Expand Down
4 changes: 4 additions & 0 deletions lib/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ function runOne(cli, compressor) {
output: cli.output
};

if (cli.option) {
options.options = JSON.parse(cli.option);
}

spinner.start(options);

return compress(options)
Expand Down

0 comments on commit 599395a

Please sign in to comment.