forked from nodegit/nodegit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckPrepared.js
More file actions
67 lines (59 loc) · 1.72 KB
/
checkPrepared.js
File metadata and controls
67 lines (59 loc) · 1.72 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
var Promise = require("nodegit-promise");
var path = require("path");
var fs = require("fs");
var rooted = path.join.bind(path, __dirname, "..");
var pkg = require(rooted("package"));
var NODE_VERSION = Number(process.version.match(/^v(\d+\.\d+)/)[1]);
module.exports.checkAll = function checkAll() {
return Promise.all([
checkVendor("libgit2"),
checkVendor("libssh2"),
checkVendor("http_parser"),
checkExists("lib/nodegit.js"),
checkExists("lib/enums.js"),
checkExists("src"),
checkExists("include")
]).then(function(checks) {
return checks.reduce(function(soFar, currentCheck) {
return soFar && currentCheck;
}, true);
});
};
function checkExists(name) {
return new Promise(function(resolve, reject) {
fs.exists(rooted(name), function(exists) {
resolve(exists);
});
});
}
module.exports.checkExists = checkExists;
function checkVendor(name, skipVersion) {
var version = "";
if (!skipVersion) {
var vendorPackage = pkg[name];
if (NODE_VERSION === 0.1 && vendorPackage["0.10"]) {
vendorPackage = vendorPackage["0.10"];
}
version = vendorPackage.sha || vendorPackage.version;
}
var vendorPath = "vendor/" + name + "/" + version;
return checkExists(vendorPath);
}
module.exports.checkVendor = checkVendor;
function checkGenerated() {
return Promise.all([
checkExists("lib/nodegit.js"),
checkExists("lib/enums.js"),
checkExists("src"),
checkExists("include")
]).then(function(checks) {
return checks.reduce(function(soFar, currentCheck) {
return soFar && currentCheck;
}, true);
});
}
module.exports.checkGenerated = checkGenerated;
// Called on the command line
if (require.main === module) {
module.exports.checkAll();
}