-
Notifications
You must be signed in to change notification settings - Fork 183
/
check.js
51 lines (48 loc) · 1.42 KB
/
check.js
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
// Exports a function to check that all source files and dependencies exist.
/* eslint-disable no-console */
var fs = require("fs");
module.exports = function() {
var missing = [];
var traverse = function(obj) {
if (Array.isArray(obj)) {
obj.forEach(function(path) {
if (path.indexOf("*") === -1 &&
path.indexOf("build/tmpl") === -1) {
try {
fs.statSync(path);
} catch (e) {
missing.push(path);
}
}
});
} else {
for (var i in obj) {
if (obj.hasOwnProperty(i)) {
traverse(obj[i]);
}
}
}
};
traverse(require("./build-paths.json"));
if (missing.length > 0) {
var bower = false;
var submodule = false;
console.log("missing files:");
missing.forEach(function(path) {
console.log(path);
if (path.indexOf("bower_components") !== -1) {
bower = true;
} else {
submodule = true;
}
});
console.log("make sure to run:");
if (bower) {
console.log(" bower install");
}
if (submodule) {
console.log(" git submodule update --init --recursive");
}
}
return missing;
};