Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add command line options to control compacting and comment removal #754

Merged
merged 2 commits into from
Jan 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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