Print an error if outSourceMap is used and source-map is missing

This commit is contained in:
Jérémy Lal 2014-05-02 01:01:46 +02:00
parent 7bf59b5bcd
commit ed983e344d

View File

@ -2,11 +2,16 @@ var path = require("path");
var fs = require("fs");
var vm = require("vm");
var sys = require("util");
var sourceMap;
try {
sourceMap = require("source-map");
} catch(e) {
}
var UglifyJS = vm.createContext({
sys : sys,
console : console,
MOZ_SourceMap : require("source-map")
MOZ_SourceMap : sourceMap
});
function load_global(file) {
@ -107,6 +112,7 @@ exports.minify = function(files, options) {
inMap = fs.readFileSync(options.inSourceMap, "utf8");
}
if (options.outSourceMap) {
if (sourceMap) {
output.source_map = UglifyJS.SourceMap({
file: options.outSourceMap,
orig: inMap,
@ -119,6 +125,9 @@ exports.minify = function(files, options) {
}
}
}
} else {
console.error("source-map module is missing and needed by outSourceMap option");
}
}
if (options.output) {