Skip to content

Commit

Permalink
fix: proper passing of the preserveComments option to babel (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
karottenreibe authored and bcoe committed Feb 13, 2018
1 parent 45936de commit 470bb0e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/istanbul-lib-instrument/src/instrumenter.js
Expand Up @@ -106,6 +106,7 @@ class Instrumenter {

const generateOptions = {
compact: opts.compact,
comments: opts.preserveComments,
sourceMaps: opts.produceSourceMap,
sourceFileName: filename
};
Expand Down
12 changes: 12 additions & 0 deletions packages/istanbul-lib-instrument/test/index.test.js
Expand Up @@ -13,3 +13,15 @@ describe('external interface', function () {
assert.isFunction(pc);
});
});

describe('instrumenter', function() {
it('should remove comments when asked to', function() {
const instrumenter = index.createInstrumenter({
preserveComments: false
});
const instrumentedCode = instrumenter.instrumentSync('/*foo*/\n//bar\ncode = true', 'somefile.js');
assert.equal(instrumentedCode.indexOf('foo'), -1, 'block comment not removed');
assert.equal(instrumentedCode.indexOf('bar'), -1, 'line comment not removed');
});
});

2 changes: 1 addition & 1 deletion packages/istanbul-lib-instrument/test/varia.test.js
Expand Up @@ -36,7 +36,7 @@ describe('varia', function () {
});

it('preserves comments when requested', function () {
var v = verifier.create('/* hello */\noutput = args[0];', { preserveComments: true }),
var v = verifier.create('/* hello */\noutput = args[0];', {}, { preserveComments: true }),
code;
assert.ok(!v.err);
v.verify(['X'], 'X',{
Expand Down

0 comments on commit 470bb0e

Please sign in to comment.