-
Notifications
You must be signed in to change notification settings - Fork 699
Expand file tree
/
Copy pathnodegit.js
More file actions
45 lines (41 loc) · 1.15 KB
/
nodegit.js
File metadata and controls
45 lines (41 loc) · 1.15 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
var fs = require('fs');
var rimraf = require('rimraf');
var ncp = require('ncp').ncp;
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('.reposCache',function() {
async.series([
function empty(cb) { exec('git init .reposCache/empty',cb); },
function workdir(cb) { exec('git clone https://github.com/nodegit/nodegit.git .reposCache/workdir',cb); },
function nonrepo(cb) {
fs.mkdir('.reposCache/nonrepo',function() {
fs.writeFile('.reposCache/nonrepo/file.txt','This is a bogus file',cb);
});
}
],cb);
});
}
module.exports = {
setUp: function(cb) {
fs.exists('.reposCache',function(exists) {
if (exists) {
ncp('.reposCache','repos',cb);
} else {
setupReposCache(function(err) {
if (err) { return cb(err); }
ncp('.reposCache','repos',cb);
});
}
});
},
tearDown: function(cb) {
rimraf('repos',cb);
}
};
for(var i in testFiles) {
var testFile = testFiles[i];
module.exports[testFile] = require('./'+testFile);
}