From 12f71e01d02a2f4cc76cb8471036992e0cba9cf1 Mon Sep 17 00:00:00 2001 From: Mihai Bazon Date: Sat, 20 Oct 2012 11:12:21 +0300 Subject: [PATCH] alternate hack to disable deprecation warning ref #9, close #20 --- tools/node.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/tools/node.js b/tools/node.js index 6a21710a..86df2a9f 100644 --- a/tools/node.js +++ b/tools/node.js @@ -1,27 +1,25 @@ -var save_stderr = process.stderr; +var path = require("path"); var fs = require("fs"); -// discard annoying NodeJS warning ("path.existsSync is now called `fs.existsSync`.") -var devnull = fs.createWriteStream("/dev/null"); -process.__defineGetter__("stderr", function(){ - return devnull; -}); +// Avoid NodeJS warning. +// +// There's a --no-deprecation command line argument supported by +// 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 sys = require("util"); -var path = require("path"); var UglifyJS = vm.createContext({ sys : sys, console : console, - MOZ_SourceMap : require("source-map") }); -process.__defineGetter__("stderr", function(){ - return save_stderr; -}); - function load_global(file) { file = path.resolve(path.dirname(module.filename), file); try { -- 2.34.1