-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathfs.js
33 lines (30 loc) · 883 Bytes
/
fs.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
"use strict";
var backends = require('backends');
var prefs = require('prefs');
// Data for repos is keyed by path. The root config is keyed by "".
// Live js-git instances by path
var repos = {};
// Config data by path
var configs = prefs.get("configs", {});
// Store the hash to the current root node
var rootHash = prefs.get("rootHash");
module.exports = require('git-tree')({
configs: configs,
repos: repos,
getRootHash: function () { return rootHash; },
setRootHash: function (hash) {
rootHash = hash;
prefs.set("rootHash", hash);
},
saveConfig: prefs.save,
createRepo: createRepo,
});
module.exports.repos = repos;
module.exports.configs = configs;
// Create a repo instance from a config
function createRepo(config) {
for (var i = 0, l = backends.length; i < l; i++) {
var repo = backends[i].createRepo(config);
if (repo) return repo;
}
}