forked from nodegit/nodegit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnodegit.js
More file actions
40 lines (36 loc) · 1.09 KB
/
nodegit.js
File metadata and controls
40 lines (36 loc) · 1.09 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
var fs = require('fs');
var rimraf = require('rimraf');
var exec = require('child_process').exec;
var path = require('path');
var async = require('async');
var testFiles = ['blob','difflist','oid','repo','tree_entry','commit','reference','revwalk','tree'];
function setupReposCache(cb) {
fs.mkdir('repos',function() {
async.series([
function empty(cb) { exec('git init repos/empty',function() { cb(); }); },
function workdir(cb) { exec('git clone https://github.com/nodegit/nodegit.git repos/workdir',function() { cb(); }); },
function nonrepo(cb) {
fs.mkdir('repos/nonrepo',function() {
fs.writeFile('repos/nonrepo/file.txt','This is a bogus file',function() {
cb();
});
});
}
],function() {
cb();
});
});
}
exports.setUp = function(cb) {
fs.exists('.reposCache', function(exists) {
if (!exists) {
setupReposCache(function(err) {
cb();
});
}
});
};
Object.keys(testFiles).forEach(function(fileName) {
var testFile = testFiles[fileName]
exports[testFile] = require('./' + testFile);
});