THRIFT-4625: Use let/const variable decorators in ES6 Javascript
diff --git a/lib/js/test/test_handler.js b/lib/js/test/test_handler.js
index 496b5e0..af5f7bd 100644
--- a/lib/js/test/test_handler.js
+++ b/lib/js/test/test_handler.js
@@ -20,10 +20,12 @@
 //This is the server side Node test handler for the standard
 //  Apache Thrift test service.
 
-var ttypes = require('./gen-nodejs/ThriftTest_types');
-var TException = require('../../nodejs/lib/thrift').TException;
+const es6Mode = process.argv.includes('--es6');
+const genFolder = es6Mode ? 'gen-nodejs-es6' : 'gen-nodejs';
+const ttypes = require(`./${genFolder}/ThriftTest_types`);
+const TException = require('../../nodejs/lib/thrift').TException;
 
-var ThriftTestHandler = exports.ThriftTestHandler = {
+exports.ThriftTestHandler = {
   testVoid: function(result) {
     console.log('testVoid()');
     result(null);
@@ -99,10 +101,10 @@
   testMapMap: function(hello, result) {
     console.log('testMapMap(' + hello + ')');
 
-    var mapmap = [];
-    var pos = [];
-    var neg = [];
-    for (var i = 1; i < 5; i++) {
+    const mapmap = [];
+    const pos = [];
+    const neg = [];
+    for (let i = 1; i < 5; i++) {
       pos[i] = i;
       neg[-i] = -i;
     }
@@ -116,34 +118,34 @@
     console.log(argument);
     console.log(')');
 
-    var hello = new ttypes.Xtruct();
+    const hello = new ttypes.Xtruct();
     hello.string_thing = 'Hello2';
     hello.byte_thing = 2;
     hello.i32_thing = 2;
     hello.i64_thing = 2;
 
-    var goodbye = new ttypes.Xtruct();
+    const goodbye = new ttypes.Xtruct();
     goodbye.string_thing = 'Goodbye4';
     goodbye.byte_thing = 4;
     goodbye.i32_thing = 4;
     goodbye.i64_thing = 4;
 
-    var crazy = new ttypes.Insanity();
+    const crazy = new ttypes.Insanity();
     crazy.userMap = [];
     crazy.userMap[ttypes.Numberz.EIGHT] = 8;
     crazy.userMap[ttypes.Numberz.FIVE] = 5;
     crazy.xtructs = [goodbye, hello];
 
-    var first_map = [];
-    var second_map = [];
+    const first_map = [];
+    const second_map = [];
 
     first_map[ttypes.Numberz.TWO] = crazy;
     first_map[ttypes.Numberz.THREE] = crazy;
 
-    var looney = new ttypes.Insanity();
+    const looney = new ttypes.Insanity();
     second_map[ttypes.Numberz.SIX] = looney;
 
-    var insane = [];
+    const insane = [];
     insane[1] = first_map;
     insane[2] = second_map;
 
@@ -154,7 +156,7 @@
   testMulti: function(arg0, arg1, arg2, arg3, arg4, arg5, result) {
     console.log('testMulti()');
 
-    var hello = new ttypes.Xtruct();
+    const hello = new ttypes.Xtruct();
     hello.string_thing = 'Hello2';
     hello.byte_thing = arg0;
     hello.i32_thing = arg1;
@@ -164,7 +166,7 @@
   testException: function(arg, result) {
     console.log('testException(' + arg + ')');
     if (arg === 'Xception') {
-      var x = new ttypes.Xception();
+      const x = new ttypes.Xception();
       x.errorCode = 1001;
       x.message = arg;
       result(x);
@@ -177,19 +179,19 @@
   testMultiException: function(arg0, arg1, result) {
     console.log('testMultiException(' + arg0 + ', ' + arg1 + ')');
     if (arg0 === ('Xception')) {
-      var x = new ttypes.Xception();
+      const x = new ttypes.Xception();
       x.errorCode = 1001;
       x.message = 'This is an Xception';
       result(x);
     } else if (arg0 === ('Xception2')) {
-      var x2 = new ttypes.Xception2();
+      const x2 = new ttypes.Xception2();
       x2.errorCode = 2002;
       x2.struct_thing = new ttypes.Xtruct();
       x2.struct_thing.string_thing = 'This is an Xception2';
       result(x2);
     }
 
-    var res = new ttypes.Xtruct();
+    const res = new ttypes.Xtruct();
     res.string_thing = arg1;
     result(null, res);
   },