Permalink
Browse files

process: add `process.config`

This is the JS representation of the `config.gypi` file that was used when
compiling node. With this information, you can tell whether the current node
binary has shared or static dependencies, or any other configuration options
that may have been used.
  • Loading branch information...
1 parent 585421e commit 293d9a271b4eae3332af1eae3586e36d139eb509 @TooTallNate committed Mar 14, 2012
Showing with 14 additions and 0 deletions.
  1. +14 −0 src/node.js
View
@@ -37,6 +37,7 @@
startup.globalConsole();
startup.processAssert();
+ startup.processConfig();
startup.processNextTick();
startup.processStdio();
startup.processKillAndExit();
@@ -177,6 +178,15 @@
};
};
+ startup.processConfig = function() {
+ config = config.split('\n').slice(1).join('\n').replace(/'/g, '"');
+ process.config = JSON.parse(config, function(key, value) {
+ if (value === 'true') return true;
+ if (value === 'false') return false;
+ return value;
+ });
+ }
+
startup.processNextTick = function() {
var nextTickQueue = [];
@@ -467,6 +477,10 @@
NativeModule._source = process.binding('natives');
NativeModule._cache = {};
+ // used for `process.config`, but not a real module
+ var config = NativeModule._source.config;
+ delete NativeModule._source.config;
+
NativeModule.require = function(id) {
if (id == 'native_module') {
return NativeModule;

0 comments on commit 293d9a2

Please sign in to comment.