Skip to content

Commit

Permalink
fix sourceRoot
Browse files Browse the repository at this point in the history
  • Loading branch information
adamloving committed Jul 1, 2014
1 parent fc56a13 commit 8a4ecd9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ module.exports.write = function write(destPath, options) {
var sourceMap = file.sourceMap;
sourceMap.file = file.relative;

if (options.sourceRoot)
sourceMap.sourceRoot = options.sourceRoot;
if (options.sourceRoot !== null)
sourceMap.sourceRoot = options.sourceRoot; // empty string is allowed

if (options.includeContent) {
sourceMap.sourceRoot = options.sourceRoot || '/source/';
Expand Down

4 comments on commit 8a4ecd9

@adamloving
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to pass in an empty string for sourceRoot. In Javascript "" (empty string) is falsy, so it was not getting set. I see this related fork svsool@69e64f9 from @svsool. However, I'm confused about what the right thing to do is without more tests.

@marckula
Copy link

@marckula marckula commented on 8a4ecd9 Jul 1, 2014 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamloving
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This small Javascript bug is definitely worth tackling to unleash the power of CoffeeScript.

@floridoo
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting sourceRoot to an empty string is the same as not setting the sourceRoot property at all in the source map (it's no mandatory field).

Please sign in to comment.