[nodejs] pass through DEBUG, NODE_DEBUG environment variables #43

set WSK_NODE_DEBUG to control NODE_DEBUG in the container, to avoid
affecting it wskdebug itself
diff --git a/src/kinds/nodejs/nodejs.js b/src/kinds/nodejs/nodejs.js
index 08f0c9f..38d6396 100644
--- a/src/kinds/nodejs/nodejs.js
+++ b/src/kinds/nodejs/nodejs.js
@@ -36,13 +36,23 @@
 
     // return extra docker arguments such as mounting the source path
     dockerArgs: function(invoker) {
+        let args = "";
         if (invoker.sourceDir) {
             if (!invoker.sourceFile) {
                 throw new Error("[source-path] or --build-path must point to the action javascript source file, it cannot be a folder.");
             }
 
-            return `-v "${invoker.sourceDir}:${CODE_MOUNT}"`;
+            args += ` -v "${invoker.sourceDir}:${CODE_MOUNT}"`;
         }
+
+        if (process.env.WSK_NODE_DEBUG) {
+            args += ` -e NODE_DEBUG='${process.env.WSK_NODE_DEBUG}'`;
+        }
+        if (process.env.DEBUG) {
+            args += ` -e DEBUG='${process.env.DEBUG}'`;
+        }
+
+        return args;
     },
 
     // return action for /init that mounts the sources specified by invoker.sourcePath
diff --git a/test/nodejs.test.js b/test/nodejs.test.js
index 9eb2f54..625e276 100644
--- a/test/nodejs.test.js
+++ b/test/nodejs.test.js
@@ -61,6 +61,9 @@
 
     afterEach(function() {
         test.afterEach();
+
+        delete process.env.DEBUG;
+        delete process.env.WSK_NODE_DEBUG;
     });
 
     it("should run an action without local sources", async function() {
@@ -548,14 +551,37 @@
         test.assertAllNocksInvoked();
     });
 
+    it("should pass through DEBUG and NODE_DEBUG env vars", async function() {
+        test.mockActionAndInvocation(
+            "myaction",
+            `function main(params) {
+                return {
+                    msg: 'CORRECT',
+                    debug: process.env.DEBUG,
+                    nodeDebug: process.env.NODE_DEBUG,
+                }
+            }`,
+            { },
+            {
+                msg: "CORRECT",
+                debug: "debug",
+                nodeDebug: "node_debug"
+            }
+        );
+
+        process.env.DEBUG = "debug";
+        process.env.WSK_NODE_DEBUG = "node_debug";
+        await wskdebug(`myaction -p ${test.port}`);
+
+        test.assertAllNocksInvoked();
+    });
+
     // TODO: test -l livereload connection
 
     // TODO: test agents - conditions (unit test agent code locally)
-    // TODO: test agent already installed (debugger.getAction())
 
     // TODO: test breakpoint debugging
     // TODO: test action options
     // TODO: test debugger options
-    // TODO: test non-concurrent openwhisk
 
 });