THRIFT-4509:
* switch from grunt-external-daemon and grunt-shell to grunt-shell-spawn
* update grunt to 1.0.2
* always use local copy of jquery and qunit
* commit the package-lock files for npm keep versions stable
Client: js

This closes #1506
diff --git a/lib/js/Gruntfile.js b/lib/js/Gruntfile.js
index 8264243..4aa450f 100644
--- a/lib/js/Gruntfile.js
+++ b/lib/js/Gruntfile.js
@@ -38,11 +38,14 @@
     },
     shell: {
       InstallThriftJS: {
-        command: 'mkdir test/build; mkdir test/build/js; cp src/thrift.js test/build/js/thrift.js'
+        command: 'mkdir test/build; mkdir test/build/js; mkdir test/build/js/lib; cp src/thrift.js test/build/js/thrift.js'
       },
       InstallThriftNodeJSDep: {
         command: 'cd ../..; npm install'
       },
+      InstallTestLibs: {
+        command: 'cd test; ant download_jslibs'
+      },
       ThriftGen: {
         command: '../../compiler/cpp/thrift -gen js -gen js:node -o test ../../test/ThriftTest.thrift'
       },
@@ -55,34 +58,26 @@
       ThriftGenES6: {
         command: '../../compiler/cpp/thrift -gen js -gen js:es6 -o test ../../test/ThriftTest.thrift'
       },
-    },
-    external_daemon: {
       ThriftTestServer: {
         options: {
-          startCheck: function(stdout, stderr) {
-            return (/Thrift Server running on port/).test(stdout);
-          },
-          nodeSpawnOptions: {
-                              cwd: "test",
-                              env: {NODE_PATH: "../../nodejs/lib:../../../node_modules"}
-                            }
+          async: true,
+          execOptions: {
+            cwd: "./test",
+            env: {NODE_PATH: "../../nodejs/lib:../../../node_modules"}
+          }
         },
-        cmd: "node",
-        args: ["server_http.js"]
+        command: "node server_http.js",
       },
       ThriftTestServer_TLS: {
         options: {
-          startCheck: function(stdout, stderr) {
-            return (/Thrift Server running on port/).test(stdout);
-          },
-          nodeSpawnOptions: {
-                              cwd: "test",
-                              env: {NODE_PATH: "../../nodejs/lib:../../../node_modules"}
-                            }
+          async: true,
+          execOptions: {
+            cwd: "./test",
+            env: {NODE_PATH: "../../nodejs/lib:../../../node_modules"}
+          }
         },
-        cmd: "node",
-        args: ["server_https.js"]
-      }
+        command: "node server_https.js",
+      },
     },
     qunit: {
       ThriftJS: {
@@ -164,16 +159,25 @@
   grunt.loadNpmTasks('grunt-contrib-qunit');
   grunt.loadNpmTasks('grunt-contrib-concat');
   grunt.loadNpmTasks('grunt-jsdoc');
-  grunt.loadNpmTasks('grunt-external-daemon');
-  grunt.loadNpmTasks('grunt-shell');
+  grunt.loadNpmTasks('grunt-shell-spawn');
+
+  grunt.registerTask('wait', 'Wait just one second for server to start', function () {
+    var done = this.async();
+    setTimeout(function() {
+      done(true);
+    }, 1000);
+  });
 
   grunt.registerTask('test', ['jshint', 'shell:InstallThriftJS', 'shell:InstallThriftNodeJSDep', 'shell:ThriftGen',
-                              'external_daemon:ThriftTestServer', 'external_daemon:ThriftTestServer_TLS',
+                              'shell:InstallTestLibs',
+                              'shell:ThriftTestServer', 'shell:ThriftTestServer_TLS',
+                              'wait',
                               'shell:ThriftGenDeepConstructor', 'qunit:ThriftDeepConstructor',
                               'qunit:ThriftJS', 'qunit:ThriftJS_TLS',
                               'qunit:ThriftWS',
                               'shell:ThriftGenJQ', 'qunit:ThriftJSJQ', 'qunit:ThriftJSJQ_TLS',
-                              'shell:ThriftGenES6', 'qunit:ThriftWSES6'
+                              'shell:ThriftGenES6', 'qunit:ThriftWSES6',
+                              'shell:ThriftTestServer:kill', 'shell:ThriftTestServer_TLS:kill',
                              ]);
   grunt.registerTask('default', ['test', 'concat', 'uglify', 'jsdoc']);
 };