forked from GoogleCloudPlatform/nodejs-docs-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall
More file actions
executable file
·82 lines (73 loc) · 2.36 KB
/
install
File metadata and controls
executable file
·82 lines (73 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/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.
var async = require('async');
var path = require('path');
require('shelljs/global');
// Install NPM dependencies, in up to 5 directories at a time
var queue = async.queue(function (directory, callback) {
installForDirectory(directory, callback);
}, 5);
queueDirectories('appengine');
queue.push('bigquery');
queue.push('computeengine');
queue.push('datastore');
queue.push('debugger');
queueDirectories('functions');
queue.push('functions/ocr/app');
queue.push('language');
queue.push('logging');
queue.push('monitoring');
queue.push('prediction');
queue.push('pubsub');
queue.push('speech');
queue.push('storage');
queue.push('trace');
queue.push('translate');
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} callback The callback function.
*/
function installForDirectory(directory, callback) {
console.log(directory + '...installing dependencies');
exec('npm install', {
async: true,
cwd: path.join(__dirname, '../', directory)
}, function (err) {
console.log(directory + '...done');
callback(err);
});
}
/**
* Recursively install NPM dependencies within a single directory.
*
* @param {string} directory The name of the directory in which to recursively install dependencies.
*/
function queueDirectories(directory) {
// Move into the directory
cd(directory);
// List the files in the directory
ls('-dl', '*')
.filter(function (file) {
// Find the directories within the directory
return file.isDirectory() && file.name !== 'test' && file.name !== 'system-test';
})
.forEach(function (file) {
queue.push(directory + '/' + file.name);
});
// Move out of the directory
cd('..');
}