-
Notifications
You must be signed in to change notification settings - Fork 2
/
nasa.core.js
47 lines (46 loc) · 1.95 KB
/
nasa.core.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
module.exports = function(fs, async){
var nasa = {
pushLocalRepositoriesToGitHub: function(repositories){
var exporter = require('./github.exporter.js');
console.log("exporting to GitHub");
async.eachSeries(repositories, exporter, function(err){
if (err)
console.log(err);
});
},
bootstrap: function(){
//Do any necessary setup in here, it will run once when the app is started.
//setup the local repositories folder
var path = __dirname + "/NASAGitRepositories";
if (!fs.existsSync(path))
fs.mkdir(path);
},
updateLocalRepositories: function(repositories, updateComplete){
var importerFiles = fs.readdirSync('./Importers');
var importers = [];
for (var i=0;i<importerFiles.length;i++) {
importers.push(require('./Importers/' + importerFiles[i]));
}
async.eachSeries(repositories, function(repository, callback){
var localRepositoryPath = __dirname + "/NASAGitRepositories/" + repository.cloneFolder;
if (!fs.existsSync(localRepositoryPath))
fs.mkdir(localRepositoryPath);
repository.cloneFolder = localRepositoryPath;
console.log("==============================");
console.log("Processing " + repository.source);
async.eachSeries(importers, function(importer, importerCallback){
importer(repository, importerCallback);
}, function(err){
callback();
});
}, function(err){
if (err)
console.log(err);
else
updateComplete();
}
);
}
}
return nasa;
}