Add support for specifying a source map URL in the to the -p/--source-map build options.

Former-commit-id: 2098da69d7902497e2e67210d778b8f99a5ff8f0
This commit is contained in:
John-David Dalton
2013-02-17 16:02:53 -08:00
parent 45bec0c440
commit 3ed9e0e905
4 changed files with 63 additions and 12 deletions

View File

@@ -645,7 +645,9 @@
(function() {
var mapCommands = [
'-p',
'--source-map'
'-p custom.map',
'--source-map',
'--source-map custom.map'
];
var outputCommands = [
@@ -661,9 +663,10 @@
var basename = path.basename(data.outputPath, '.js'),
comment = (/(\s*\/\/.*\s*|\s*\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/\s*)$/.exec(data.source) || [])[0],
sources = /foo.js/.test(outputCommand) ? ['foo.js'] : ['lodash' + (outputCommand.length ? '' : '.custom') + '.js'],
sourceMap = JSON.parse(data.sourceMap);
sourceMap = JSON.parse(data.sourceMap),
sourceMapURL = (/\w+(?=\.map$)/.exec(mapCommand) || [basename])[0];
ok(RegExp('/\\*\\n//@ sourceMappingURL=' + basename + '.map\\n\\*/').test(comment), basename);
ok(RegExp('/\\*\\n//@ sourceMappingURL=' + sourceMapURL + '.map\\n\\*/').test(comment), basename);
equal(sourceMap.file, basename + '.js', basename);
deepEqual(sourceMap.sources, sources, basename);
@@ -674,7 +677,7 @@
if (outputCommand.indexOf('-m') < 0) {
callback = _.after(2, callback);
}
build(['-s', mapCommand].concat(outputCommand), callback);
build(['-s'].concat(mapCommand.split(' '), outputCommand), callback);
});
});
});