Skip to content

Commit 2030e0c

Browse files
karottenreibebcoe
authored andcommitted
feat: add command line options to control compacting and comment removal (#754)
1 parent 6a734b6 commit 2030e0c

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ NYC.prototype.instrumenter = function () {
136136

137137
NYC.prototype._createInstrumenter = function () {
138138
return this._instrumenterLib(this.cwd, {
139-
produceSourceMap: this.config.produceSourceMap
139+
produceSourceMap: this.config.produceSourceMap,
140+
compact: this.config.compact,
141+
preserveComments: this.config.preserveComments
140142
})
141143
}
142144

lib/commands/instrument.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ exports.builder = function (yargs) {
3131
type: 'boolean',
3232
description: "should nyc's instrumenter produce source maps?"
3333
})
34+
.option('compact', {
35+
default: true,
36+
type: 'boolean',
37+
description: 'should the output be compacted?'
38+
})
39+
.option('preserve-comments', {
40+
default: true,
41+
type: 'boolean',
42+
description: 'should comments be preserved in the output?'
43+
})
3444
.option('instrument', {
3545
default: true,
3646
type: 'boolean',
@@ -50,7 +60,9 @@ exports.handler = function (argv) {
5060
sourceMap: argv.sourceMap,
5161
produceSourceMap: argv.produceSourceMap,
5262
extension: argv.extension,
53-
require: argv.require
63+
require: argv.require,
64+
compact: argv.compact,
65+
preserveComments: argv.preserveComments
5466
})
5567

5668
nyc.instrumentAllFiles(argv.input, argv.output, function (err) {

lib/config-util.js

+10
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,16 @@ Config.buildYargs = function (cwd) {
165165
description: "should nyc's instrumenter produce source maps?",
166166
global: false
167167
})
168+
.option('compact', {
169+
default: true,
170+
type: 'boolean',
171+
description: 'should the output be compacted?'
172+
})
173+
.option('preserve-comments', {
174+
default: true,
175+
type: 'boolean',
176+
description: 'should comments be preserved in the output?'
177+
})
168178
.option('instrument', {
169179
default: true,
170180
type: 'boolean',

lib/instrumenters/istanbul.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ function InstrumenterIstanbul (cwd, options) {
99
autoWrap: true,
1010
coverageVariable: '__coverage__',
1111
embedSource: true,
12-
noCompact: false,
13-
preserveComments: true,
12+
compact: options.compact,
13+
preserveComments: options.preserveComments,
1414
produceSourceMap: options.produceSourceMap,
1515
esModules: true
1616
})

0 commit comments

Comments
 (0)