THRIFT-4625: Use let/const variable decorators in ES6 Javascript
diff --git a/lib/js/test/server_https.js b/lib/js/test/server_https.js
index 7e78d9e..504f3b5 100644
--- a/lib/js/test/server_https.js
+++ b/lib/js/test/server_https.js
@@ -26,20 +26,22 @@
// support libraries for test.html (jquery.js, qunit.js and qunit.css
// in ./build/js/lib).
-var fs = require('fs');
-var thrift = require('../../nodejs/lib/thrift');
-var ThriftTestSvc = require('./gen-nodejs/ThriftTest.js');
-var ThriftTestHandler = require('./test_handler').ThriftTestHandler;
+const fs = require('fs');
+const thrift = require('../../nodejs/lib/thrift');
+const es6Mode = process.argv.includes('--es6');
+const genFolder = es6Mode ? 'gen-nodejs-es6' : 'gen-nodejs';
+const ThriftTestSvc = require(`./${genFolder}/ThriftTest.js`);
+const ThriftTestHandler = require('./test_handler').ThriftTestHandler;
//Setup the I/O stack options for the ThriftTest service
-var ThriftTestSvcOpt = {
+const ThriftTestSvcOpt = {
transport: thrift.TBufferedTransport,
protocol: thrift.TJSONProtocol,
processor: ThriftTestSvc,
handler: ThriftTestHandler
};
-var ThriftWebServerOptions = {
+const ThriftWebServerOptions = {
files: '.',
tls: {
key: fs.readFileSync('../../../test/keys/server.key'),
@@ -50,8 +52,8 @@
}
};
-var server = thrift.createWebServer(ThriftWebServerOptions);
-var port = 8089;
+const server = thrift.createWebServer(ThriftWebServerOptions);
+const port = es6Mode ? 8090 : 8091;
server.listen(port);
-console.log('Serving files from: ' + __dirname);
-console.log('Http/Thrift Server running on port: ' + port);
+console.log(`Serving files from: ${__dirname}`);
+console.log(`Http/Thrift Server (ES6 mode ${es6Mode}) running on port: ${port}`);