summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2012-06-21 11:42:33 -0700
committerisaacs <i@izs.me>2012-06-21 12:05:33 -0700
commit5b39929d47f962fccafb4116f3c177ddc4fd3269 (patch)
tree7380f2e1b3a03b7a5b5483236465b1c05c486d86 /src
parent260695afd07067254a704c050243d2e619bae8b7 (diff)
downloadnode-5b39929d47f962fccafb4116f3c177ddc4fd3269.tar.gz
Add --no-deprecation and --trace-deprecation flags
Diffstat (limited to 'src')
-rw-r--r--src/node.cc32
-rw-r--r--src/node.js29
2 files changed, 28 insertions, 33 deletions
diff --git a/src/node.cc b/src/node.cc
index d71a21b69..94cc2a5f4 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -120,6 +120,8 @@ static Persistent<String> disposed_symbol;
static bool print_eval = false;
static bool force_repl = false;
+static bool no_deprecation = false;
+static bool trace_deprecation = false;
static char *eval_string = NULL;
static int option_end_index = 0;
static bool use_debug_agent = false;
@@ -1094,12 +1096,16 @@ enum encoding ParseEncoding(Handle<Value> encoding_v, enum encoding _default) {
} else if (strcasecmp(*encoding, "hex") == 0) {
return HEX;
} else if (strcasecmp(*encoding, "raw") == 0) {
- fprintf(stderr, "'raw' (array of integers) has been removed. "
- "Use 'binary'.\n");
+ if (!no_deprecation) {
+ fprintf(stderr, "'raw' (array of integers) has been removed. "
+ "Use 'binary'.\n");
+ }
return BINARY;
} else if (strcasecmp(*encoding, "raws") == 0) {
- fprintf(stderr, "'raws' encoding has been renamed to 'binary'. "
- "Please update your code.\n");
+ if (!no_deprecation) {
+ fprintf(stderr, "'raws' encoding has been renamed to 'binary'. "
+ "Please update your code.\n");
+ }
return BINARY;
} else {
return _default;
@@ -2224,6 +2230,16 @@ Handle<Object> SetupProcessObject(int argc, char *argv[]) {
process->Set(String::NewSymbol("_forceRepl"), True());
}
+ // --no-deprecation
+ if (no_deprecation) {
+ process->Set(String::NewSymbol("noDeprecation"), True());
+ }
+
+ // --trace-deprecation
+ if (trace_deprecation) {
+ process->Set(String::NewSymbol("traceDeprecation"), True());
+ }
+
size_t size = 2*PATH_MAX;
char* execPath = new char[size];
if (uv_exepath(execPath, &size) != 0) {
@@ -2371,6 +2387,8 @@ static void PrintHelp() {
" -p, --print print result of --eval\n"
" -i, --interactive always enter the REPL even if stdin\n"
" does not appear to be a terminal\n"
+ " --no-deprecation silence deprecation warnings\n"
+ " --trace-deprecation show stack traces on deprecations\n"
" --v8-options print v8 command line options\n"
" --max-stack-size=val set max v8 stack size (bytes)\n"
"\n"
@@ -2428,6 +2446,12 @@ static void ParseArgs(int argc, char **argv) {
argv[i] = const_cast<char*>("");
} else if (strcmp(arg, "--v8-options") == 0) {
argv[i] = const_cast<char*>("--help");
+ } else if (strcmp(arg, "--no-deprecation") == 0) {
+ argv[i] = const_cast<char*>("");
+ no_deprecation = true;
+ } else if (strcmp(arg, "--trace-deprecation") == 0) {
+ argv[i] = const_cast<char*>("");
+ trace_deprecation = true;
} else if (argv[i][0] != '-') {
break;
}
diff --git a/src/node.js b/src/node.js
index b2a0277a4..6a202fbce 100644
--- a/src/node.js
+++ b/src/node.js
@@ -600,34 +600,5 @@
NativeModule._cache[this.id] = this;
};
- // Wrap a core module's method in a wrapper that will warn on first use
- // and then return the result of invoking the original function. After
- // first being called the original method is restored.
- NativeModule.prototype.deprecate = function(method, message) {
- var original = this.exports[method];
- var self = this;
- var warned = false;
- message = message || '';
-
- Object.defineProperty(this.exports, method, {
- enumerable: false,
- value: function() {
- if (!warned) {
- warned = true;
- message = self.id + '.' + method + ' is deprecated. ' + message;
-
- var moduleIdCheck = new RegExp('\\b' + self.id + '\\b');
- if (moduleIdCheck.test(process.env.NODE_DEBUG))
- console.trace(message);
- else
- console.error(message);
-
- self.exports[method] = original;
- }
- return original.apply(this, arguments);
- }
- });
- };
-
startup();
});