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

7
src/node.cc

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

24
src/node.js

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

Loading…
Cancel
Save