alternate hack to disable deprecation warning

ref #9, close #20
This commit is contained in:
Mihai Bazon
2012-10-20 11:12:21 +03:00
parent fc8314e810
commit 12f71e01d0

View File

@@ -1,27 +1,25 @@
var save_stderr = process.stderr; var path = require("path");
var fs = require("fs"); var fs = require("fs");
// discard annoying NodeJS warning ("path.existsSync is now called `fs.existsSync`.") // Avoid NodeJS warning.
var devnull = fs.createWriteStream("/dev/null"); //
process.__defineGetter__("stderr", function(){ // There's a --no-deprecation command line argument supported by
return devnull; // NodeJS, but that's tricky to use, so I'd like to set it from the
}); // program itself. Turns out you need to set `process.noDeprecation`,
// but by the time you can set that the `path` module is already
// loaded and `path.existsSync` is already changed to display that
// warning, therefore here's the poor solution:
path.existsSync = fs.existsSync;
var vm = require("vm"); var vm = require("vm");
var sys = require("util"); var sys = require("util");
var path = require("path");
var UglifyJS = vm.createContext({ var UglifyJS = vm.createContext({
sys : sys, sys : sys,
console : console, console : console,
MOZ_SourceMap : require("source-map") MOZ_SourceMap : require("source-map")
}); });
process.__defineGetter__("stderr", function(){
return save_stderr;
});
function load_global(file) { function load_global(file) {
file = path.resolve(path.dirname(module.filename), file); file = path.resolve(path.dirname(module.filename), file);
try { try {