mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 09:47:48 +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) {
|
else if (!isStdOut) {
|
||||||
outputUsed = true;
|
outputUsed = true;
|
||||||
|
filePath = outputPath || path.join(cwd, basename + '.js');
|
||||||
callback({
|
callback({
|
||||||
'source': debugSource,
|
'source': debugSource,
|
||||||
'outputPath': outputPath || path.join(cwd, basename + '.js')
|
'outputPath': filePath
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -643,33 +643,38 @@
|
|||||||
QUnit.module('source maps');
|
QUnit.module('source maps');
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var commands = [
|
var mapCommands = [
|
||||||
'-p',
|
'-p',
|
||||||
'--source-map'
|
'--source-map'
|
||||||
];
|
];
|
||||||
|
|
||||||
var outputPaths = [
|
var outputCommands = [
|
||||||
'',
|
'',
|
||||||
'-o foo.js'
|
'-o foo.js',
|
||||||
|
'-m -o bar.js'
|
||||||
];
|
];
|
||||||
|
|
||||||
commands.forEach(function(command) {
|
mapCommands.forEach(function(mapCommand) {
|
||||||
outputPaths.forEach(function(outputPath) {
|
outputCommands.forEach(function(outputCommand) {
|
||||||
asyncTest('`lodash ' + command + (outputPath ? ' ' + outputPath : '') + '`', function() {
|
asyncTest('`lodash ' + mapCommand + (outputCommand ? ' ' + outputCommand : '') + '`', function() {
|
||||||
var start = _.once(QUnit.start);
|
var callback = _.once(function(data) {
|
||||||
outputPath = outputPath ? outputPath.split(' ') : [];
|
|
||||||
|
|
||||||
build(['-s', '-m', command].concat(outputPath), function(data) {
|
|
||||||
var basename = path.basename(data.outputPath, '.js'),
|
var basename = path.basename(data.outputPath, '.js'),
|
||||||
comment = (/(\s*\/\/.*\s*|\s*\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/\s*)$/.exec(data.source) || [])[0],
|
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);
|
||||||
|
|
||||||
ok(RegExp('/\\*\\n//@ sourceMappingURL=' + basename + '.map\\n\\*/').test(comment), basename);
|
ok(RegExp('/\\*\\n//@ sourceMappingURL=' + basename + '.map\\n\\*/').test(comment), basename);
|
||||||
equal(sourceMap.file, basename + '.js', 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