Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Downcase process.ARGV/ENV to process.argv/env
  • Loading branch information
ry committed Feb 3, 2010
1 parent 8f52142 commit f3ad635
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
8 changes: 4 additions & 4 deletions doc/api.txt
Expand Up @@ -48,7 +48,7 @@ execution.

=== Global Objects

+GLOBAL+ ::
+global+ ::
The global namespace object.

+process+ ::
Expand Down Expand Up @@ -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+ ::
Expand Down Expand Up @@ -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:
+
Expand Down
7 changes: 5 additions & 2 deletions src/node.cc
Expand Up @@ -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]));
Expand All @@ -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
Expand All @@ -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
Expand Down
24 changes: 12 additions & 12 deletions src/node.js
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}


Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f3ad635

Please sign in to comment.