From 599395a231b569a7f5488f7545e88b70121d3bc7 Mon Sep 17 00:00:00 2001 From: Rodolphe Stoclin Date: Thu, 9 Aug 2018 22:30:22 +0200 Subject: [PATCH] feat(cli): add option to compressor --- __tests__/cli-test.js | 3 ++- bin/cli.js | 3 ++- lib/cli/index.js | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/__tests__/cli-test.js b/__tests__/cli-test.js index 1ba8a9304..d4b20a2f7 100644 --- a/__tests__/cli-test.js +++ b/__tests__/cli-test.js @@ -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(); }); diff --git a/bin/cli.js b/bin/cli.js index 617bd1b17..b4e216256 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -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:'); diff --git a/lib/cli/index.js b/lib/cli/index.js index 1b3a803a4..b3c62d52e 100644 --- a/lib/cli/index.js +++ b/lib/cli/index.js @@ -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)