#!/usr/bin/env node /** * Copyright 2016, Google, Inc. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ const async = require('async'); const path = require('path'); require('shelljs/global'); // Run the command in up to 7 directories at a time const queue = async.queue((directory, callback) => { runForDirectory(directory, callback); }, 4); queue.push('appengine/bower'); queue.push('appengine/express-memcached-session'); queue.push('appengine/geddy'); queue.push('appengine/grunt'); queue.push('appengine/hapi'); queue.push('appengine/koa'); queue.push('appengine/kraken'); queue.push('appengine/loopback'); queue.push('appengine/mailgun'); queue.push('appengine/mailjet'); queue.push('appengine/memcached'); queue.push('appengine/mongodb'); queue.push('appengine/parse-server'); queue.push('appengine/restify'); queue.push('appengine/sails'); queue.push('appengine/twilio'); queue.push('appengine/webpack'); queue.push('appengine/websockets'); /** * Run the command in the given directory * * @param {string} directory The name of the directory in which to run the * command. * @param {function} callback The callback function. */ function runForDirectory(directory, callback) { console.log(`${directory}...running "yarn install"`); exec('yarn install', { async: true, cwd: path.join(__dirname, '../', directory) }, function (err) { console.log(`${directory}...done`); callback(err); }); } /** * Recursively run the command within a single directory. * * @param {string} directory The name of the directory in which to recursively * run the command. */ function queueDirectories(directory) { // Move into the directory cd(directory); // List the files in the directory ls('-dl', '*') // Find the directories within the directory .filter((file) => file.isDirectory() && file.name !== 'test' && file.name !== 'system-test') .forEach((file) => { queue.push(path.join(directory, file.name)); }); // Move out of the directory cd('..'); }