From 624dd38d898d9a69a60320010d8598823ab1f603 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Sun, 31 Jul 2011 17:51:41 -0700 Subject: [PATCH] child_process_uv: fix test/simple/test-child-process-env --- Makefile | 1 + lib/child_process_uv.js | 10 +++++++++- src/process_wrap.cc | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index c574d27d531..244d1e48cda 100644 --- a/Makefile +++ b/Makefile @@ -238,6 +238,7 @@ UVTEST += simple/test-child-process-exit-code UVTEST += simple/test-child-process-buffering UVTEST += simple/test-child-process-exec-cwd UVTEST += simple/test-child-process-cwd +UVTEST += simple/test-child-process-env test-uv: all diff --git a/lib/child_process_uv.js b/lib/child_process_uv.js index 6352c93828e..5902ac31bbd 100644 --- a/lib/child_process_uv.js +++ b/lib/child_process_uv.js @@ -172,10 +172,18 @@ var spawn = exports.spawn = function(file, args, options) { var args = args ? args.slice(0) : []; args.unshift(file); + var env = (options ? options.env : null) || process.env; + var envPairs = []; + var keys = Object.keys(env); + for (var key in env) { + envPairs.push(key + '=' + env[key]); + } + child.spawn({ file: file, args: args, - cwd: options ? options.cwd : null + cwd: options ? options.cwd : null, + envPairs: envPairs }); return child; diff --git a/src/process_wrap.cc b/src/process_wrap.cc index a26e3b5330f..fc3a1697a6f 100644 --- a/src/process_wrap.cc +++ b/src/process_wrap.cc @@ -113,7 +113,7 @@ class ProcessWrap : public HandleWrap { } // options.env - Local env_v = js_options->Get(String::New("env")); + Local env_v = js_options->Get(String::New("envPairs")); if (!env_v.IsEmpty() && env_v->IsArray()) { Local env = Local::Cast(env_v); int envc = env->Length();