Skip to content

Commit

Permalink
feat: add command line options to control compacting and comment remo…
Browse files Browse the repository at this point in the history
…val (#754)
  • Loading branch information
karottenreibe authored and bcoe committed Jan 15, 2018
1 parent 6a734b6 commit 2030e0c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ NYC.prototype.instrumenter = function () {

NYC.prototype._createInstrumenter = function () {
return this._instrumenterLib(this.cwd, {
produceSourceMap: this.config.produceSourceMap
produceSourceMap: this.config.produceSourceMap,
compact: this.config.compact,
preserveComments: this.config.preserveComments
})
}

Expand Down
14 changes: 13 additions & 1 deletion lib/commands/instrument.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ exports.builder = function (yargs) {
type: 'boolean',
description: "should nyc's instrumenter produce source maps?"
})
.option('compact', {
default: true,
type: 'boolean',
description: 'should the output be compacted?'
})
.option('preserve-comments', {
default: true,
type: 'boolean',
description: 'should comments be preserved in the output?'
})
.option('instrument', {
default: true,
type: 'boolean',
Expand All @@ -50,7 +60,9 @@ exports.handler = function (argv) {
sourceMap: argv.sourceMap,
produceSourceMap: argv.produceSourceMap,
extension: argv.extension,
require: argv.require
require: argv.require,
compact: argv.compact,
preserveComments: argv.preserveComments
})

nyc.instrumentAllFiles(argv.input, argv.output, function (err) {
Expand Down
10 changes: 10 additions & 0 deletions lib/config-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,16 @@ Config.buildYargs = function (cwd) {
description: "should nyc's instrumenter produce source maps?",
global: false
})
.option('compact', {
default: true,
type: 'boolean',
description: 'should the output be compacted?'
})
.option('preserve-comments', {
default: true,
type: 'boolean',
description: 'should comments be preserved in the output?'
})
.option('instrument', {
default: true,
type: 'boolean',
Expand Down
4 changes: 2 additions & 2 deletions lib/instrumenters/istanbul.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ function InstrumenterIstanbul (cwd, options) {
autoWrap: true,
coverageVariable: '__coverage__',
embedSource: true,
noCompact: false,
preserveComments: true,
compact: options.compact,
preserveComments: options.preserveComments,
produceSourceMap: options.produceSourceMap,
esModules: true
})
Expand Down

0 comments on commit 2030e0c

Please sign in to comment.