Skip to content

Commit

Permalink
Merge bf6f35d into 492d937
Browse files Browse the repository at this point in the history
  • Loading branch information
nmccready committed Feb 7, 2019
2 parents 492d937 + bf6f35d commit 0425335
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ cache:
- node_modules

install:
- npm i -g npm@4.5.X
- npm i -g yarn
- npm install

after_script:
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
"vinyl": "2.X",
"yargs": "7.X"
},
"resolutions": {
"flush-write-stream": "1.0.3"
},
"files": [
"index.js",
"src"
Expand Down
52 changes: 25 additions & 27 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,40 +19,38 @@ So we either need to use a new instance of a regex everywhere.
*/
var sourceMapUrlRegEx = function(){ return /\/\/\# sourceMappingURL\=.*/g;};

var commentFormatters = {
css: function cssCommentFormatter(preLine, newline, url) {
return preLine + "/*# sourceMappingURL=" + url + " */" + newline;
},
js: function jsCommentFormatter(preLine, newline, url) {
return preLine + "//# sourceMappingURL=" + url + newline;
},
'default': function defaultFormatter() {
return '';
}
}


var getCommentFormatter = function (file) {
var extension = file.relative.split('.').pop(),
fileContents = file.contents.toString(),
newline = detectNewline.graceful(fileContents || ''),
commentFormatter = function(url) {
return '';
};
fileContents = file.contents.toString(),
newline = detectNewline.graceful(fileContents || '');

if (file.sourceMap.preExistingComment){
debug(function() { return 'preExistingComment commentFormatter'; });
commentFormatter = function(url) {
return "//# sourceMappingURL=" + url + newline;
};
return commentFormatter;
}
var commentFormatter = commentFormatters.default;

switch (extension) {
case 'css':
debug(function() { return 'css commentFormatter';});
commentFormatter = function(url) {
return newline + "/*# sourceMappingURL=" + url + " */" + newline;
};
break;
case 'js':
debug(function() { return 'js commentFormatter'; });
commentFormatter = function(url) {
return newline + "//# sourceMappingURL=" + url + newline;
};
break;
default:
debug(function() { return 'unknown commentFormatter'; });
if (file.sourceMap.preExistingComment) {
commentFormatter = (commentFormatters[extension] || commentFormatter).bind(undefined, '', newline)
debug(function () {
return 'preExistingComment commentFormatter ' + commentFormatter.name;
});
} else {
commentFormatter = (commentFormatters[extension] || commentFormatter).bind(undefined, newline, newline);
}

debug(function () {
return 'commentFormatter ' + commentFormatter.name;
});
return commentFormatter;
};

Expand Down

0 comments on commit 0425335

Please sign in to comment.