diff --git a/scripts/install b/scripts/install index 358bb8a649..fb1f8c28bb 100755 --- a/scripts/install +++ b/scripts/install @@ -13,14 +13,14 @@ // See the License for the specific language governing permissions and // limitations under the License. -const async = require('async'); -const path = require('path'); +var async = require('async'); +var path = require('path'); require('shelljs/global'); // Install NPM dependencies, in up to 7 directories at a time -const queue = async.queue((directory, cb) => { - installForDirectory(directory, cb); +var queue = async.queue(function (directory, callback) { + installForDirectory(directory, callback); }, 7); queueDirectories('appengine'); @@ -47,39 +47,16 @@ queue.push('vision'); * Install NPM dependencies within a single directory. * * @param {string} directory The name of the directory in which to install dependencies. - * @param {function} cb The callback function. + * @param {function} callback The callback function. */ -function installForDirectory (directory, cb) { - console.log(`${directory}...installing dependencies`); - exec('yarn install', { +function installForDirectory(directory, callback) { + console.log(directory + '...installing dependencies'); + exec('npm install', { async: true, cwd: path.join(__dirname, '../', directory) - }, (err) => { - if (err) { - cd(directory); - - // Uninstall dependencies - console.log(`Retrying in ${directory} with NPM...`); - rm('-rf', 'node_modules'); - - // Move out of the directory - cd('..'); - exec('npm install', { - async: true, - cwd: path.join(__dirname, '../', directory) - }, (err) => { - if (err) { - console.error(`Failed to install dependencies in ${directory}!`); - throw err; - } else { - console.log(`${directory}...done`); - cb(); - } - }); - } else { - console.log(`${directory}...done`); - cb(); - } + }, function (err) { + console.log(directory + '...done'); + callback(err); }); } @@ -88,18 +65,20 @@ function installForDirectory (directory, cb) { * * @param {string} directory The name of the directory in which to recursively install dependencies. */ -function queueDirectories (directory) { +function queueDirectories(directory) { // Move into the directory cd(directory); // List the files in the directory ls('-dl', '*') - .filter((file) => { + .filter(function (file) { // Find the directories within the directory return file.isDirectory() && file.name !== 'test' && file.name !== 'system-test'; }) - .forEach((file) => queue.push(`${directory}/${file.name}`)); + .forEach(function (file) { + queue.push(directory + '/' + file.name); + }); // Move out of the directory cd('..'); -} +} \ No newline at end of file diff --git a/scripts/uninstall b/scripts/uninstall index af90f447f2..04600d367e 100755 --- a/scripts/uninstall +++ b/scripts/uninstall @@ -84,4 +84,4 @@ function queueDirectories(directory) { // Move out of the directory cd('..'); -} +} \ No newline at end of file