Browse Source

Downcase process.ARGV/ENV to process.argv/env

v0.7.4-release
Ryan Dahl 15 years ago
parent
commit
f3ad635576
  1. 8
      doc/api.txt
  2. 7
      src/node.cc
  3. 24
      src/node.js

8
doc/api.txt

@ -48,7 +48,7 @@ execution.
=== Global Objects
+GLOBAL+ ::
+global+ ::
The global namespace object.
+process+ ::
@ -100,10 +100,10 @@ more information.
signal names such as SIGINT, SIGUSR1, etc.
|=========================================================
+process.ARGV+ ::
+process.argv+ ::
An array containing the command line arguments.
+process.ENV+ ::
+process.env+ ::
An object containing the user environment. See environ(7).
+process.pid+ ::
@ -565,7 +565,7 @@ Node provides a tridirectional +popen(3)+ facility through the class
+"error"+ callbacks will no longer be made.
|=========================================================
+process.createChildProcess(command, args=[], env=ENV)+::
+process.createChildProcess(command, args=[], env=process.env)+::
Launches a new process with the given +command+, command line arguments, and
environmental variables. For example:
+

7
src/node.cc

@ -914,7 +914,7 @@ static void Load(int argc, char *argv[]) {
#define str(s) #s
process->Set(String::NewSymbol("platform"), String::New(xstr(PLATFORM)));
// process.ARGV
// process.argv
int i, j;
Local<Array> arguments = Array::New(argc - dash_dash_index + 1);
arguments->Set(Integer::New(0), String::New(argv[0]));
@ -924,8 +924,9 @@ static void Load(int argc, char *argv[]) {
}
// assign it
process->Set(String::NewSymbol("ARGV"), arguments);
process->Set(String::NewSymbol("argv"), arguments);
// create process.ENV
// create process.env
Local<Object> env = Object::New();
for (i = 0; environ[i]; i++) {
// skip entries without a '=' character
@ -941,6 +942,8 @@ static void Load(int argc, char *argv[]) {
}
// assign process.ENV
process->Set(String::NewSymbol("ENV"), env);
process->Set(String::NewSymbol("env"), env);
process->Set(String::NewSymbol("pid"), Integer::New(getpid()));
// define various internal methods

24
src/node.js

@ -86,7 +86,7 @@ process.inherits = function (ctor, superCtor) {
process.createChildProcess = function (file, args, env) {
var child = new process.ChildProcess();
args = args || [];
env = env || process.ENV;
env = env || process.env;
var envPairs = [];
for (var key in env) {
if (env.hasOwnProperty(key)) {
@ -493,7 +493,7 @@ GLOBAL.clearInterval = GLOBAL.clearTimeout;
// Modules
var debugLevel = 0;
if ("NODE_DEBUG" in process.ENV) debugLevel = 1;
if ("NODE_DEBUG" in process.env) debugLevel = 1;
function debug (x) {
if (debugLevel > 0) {
@ -744,12 +744,12 @@ var path = pathModule.exports;
process.paths = [ path.join(process.installPrefix, "lib/node/libraries")
];
if (process.ENV["HOME"]) {
process.paths.unshift(path.join(process.ENV["HOME"], ".node_libraries"));
if (process.env["HOME"]) {
process.paths.unshift(path.join(process.env["HOME"], ".node_libraries"));
}
if (process.ENV["NODE_PATH"]) {
process.paths = process.ENV["NODE_PATH"].split(":").concat(process.paths);
if (process.env["NODE_PATH"]) {
process.paths = process.env["NODE_PATH"].split(":").concat(process.paths);
}
@ -968,19 +968,19 @@ process.exit = function (code) {
var cwd = process.cwd();
// Make process.ARGV[0] and process.ARGV[1] into full paths.
if (process.ARGV[0].indexOf('/') > 0) {
process.ARGV[0] = path.join(cwd, process.ARGV[0]);
// Make process.argv[0] and process.argv[1] into full paths.
if (process.argv[0].indexOf('/') > 0) {
process.argv[0] = path.join(cwd, process.argv[0]);
}
if (process.ARGV[1].charAt(0) != "/" && !(/^http:\/\//).exec(process.ARGV[1])) {
process.ARGV[1] = path.join(cwd, process.ARGV[1]);
if (process.argv[1].charAt(0) != "/" && !(/^http:\/\//).exec(process.argv[1])) {
process.argv[1] = path.join(cwd, process.argv[1]);
}
// Load the main module--the command line argument.
process.mainModule = createModule(".");
var loadPromise = new events.Promise();
process.mainModule.load(process.ARGV[1], loadPromise);
process.mainModule.load(process.argv[1], loadPromise);
// All our arguments are loaded. We've evaluated all of the scripts. We
// might even have created TCP servers. Now we enter the main eventloop. If

Loading…
Cancel
Save