Skip to content

Commit

Permalink
fix(example): use disableSourceMap option
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed Aug 24, 2019
1 parent 73701eb commit 04c1e32
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
3 changes: 2 additions & 1 deletion packages/comment-to-assert/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,5 @@ crashlytics-build.properties



/lib
/lib
lib
9 changes: 3 additions & 6 deletions packages/comment-to-assert/example/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
"use strict";
var assert = require("assert");
var toAssertFromSource = require("comment-to-assert").toAssertFromSource;
var resultOfPrimitive = toAssertFromSource("1;// => 1");
assert.equal(resultOfPrimitive, 'assert.equal(1, 1);');
var resultOfObject = toAssertFromSource("[1];// => [1]");
assert.equal(resultOfObject, 'assert.deepEqual([1], [1]);');
var resultOfIdentifier = toAssertFromSource("var foo=1;foo;// => 1");
assert.equal(resultOfIdentifier, 'var foo = 1;\nassert.equal(foo, 1);');
toAssertFromSource("1;// => 1");// => 'assert.equal(1, 1);'
toAssertFromSource("[1];// => [1]");// => 'assert.deepEqual([1], [1]);'
toAssertFromSource("var foo=1;foo;// => 1");// => 'var foo = 1;\nassert.equal(foo, 1);'
3 changes: 2 additions & 1 deletion packages/comment-to-assert/src/comment-to-assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import {
*/
export function toAssertFromSource(code, filePath) {
var source = new ASTSource(code, {
filePath: filePath
filePath: filePath,
disableSourceMap: typeof filePath === "undefined"
});
var output = source.transform(toAssertFromAST).output();
return output.codeWithMap;
Expand Down

0 comments on commit 04c1e32

Please sign in to comment.