mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-31 15:27:50 +00:00
Automatically set a source map's "sources" key based on the build performed.
Former-commit-id: c02c88dfd1db097a3f98113ee57c3da850da5abb
This commit is contained in:
3
build.js
3
build.js
@@ -2414,9 +2414,10 @@
|
||||
}
|
||||
else if (!isStdOut) {
|
||||
outputUsed = true;
|
||||
filePath = outputPath || path.join(cwd, basename + '.js');
|
||||
callback({
|
||||
'source': debugSource,
|
||||
'outputPath': outputPath || path.join(cwd, basename + '.js')
|
||||
'outputPath': filePath
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -643,33 +643,38 @@
|
||||
QUnit.module('source maps');
|
||||
|
||||
(function() {
|
||||
var commands = [
|
||||
var mapCommands = [
|
||||
'-p',
|
||||
'--source-map'
|
||||
];
|
||||
|
||||
var outputPaths = [
|
||||
var outputCommands = [
|
||||
'',
|
||||
'-o foo.js'
|
||||
'-o foo.js',
|
||||
'-m -o bar.js'
|
||||
];
|
||||
|
||||
commands.forEach(function(command) {
|
||||
outputPaths.forEach(function(outputPath) {
|
||||
asyncTest('`lodash ' + command + (outputPath ? ' ' + outputPath : '') + '`', function() {
|
||||
var start = _.once(QUnit.start);
|
||||
outputPath = outputPath ? outputPath.split(' ') : [];
|
||||
|
||||
build(['-s', '-m', command].concat(outputPath), function(data) {
|
||||
mapCommands.forEach(function(mapCommand) {
|
||||
outputCommands.forEach(function(outputCommand) {
|
||||
asyncTest('`lodash ' + mapCommand + (outputCommand ? ' ' + outputCommand : '') + '`', function() {
|
||||
var callback = _.once(function(data) {
|
||||
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);
|
||||
|
||||
ok(RegExp('/\\*\\n//@ sourceMappingURL=' + basename + '.map\\n\\*/').test(comment), basename);
|
||||
equal(sourceMap.file, basename + '.js', basename);
|
||||
deepEqual(sourceMap.sources, ['lodash.js'], basename);
|
||||
deepEqual(sourceMap.sources, sources, basename);
|
||||
|
||||
start();
|
||||
QUnit.start();
|
||||
});
|
||||
|
||||
outputCommand = outputCommand ? outputCommand.split(' ') : [];
|
||||
if (outputCommand.indexOf('-m') < 0) {
|
||||
callback = _.after(2, callback);
|
||||
}
|
||||
build(['-s', mapCommand].concat(outputCommand), callback);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user