summaryrefslogtreecommitdiffstats
path: root/lib/utils/git.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-02-14 11:10:08 +0100
committerSamy Pessé <samypesse@gmail.com>2016-02-14 11:10:08 +0100
commita65f888a77c48968087d23750e5fa4d55f2a8686 (patch)
treeb88e7e5b0e98ae791726586592716cd602355abf /lib/utils/git.js
parent71059e3ea3ea9af156987a0dd4cb0a5457b0316c (diff)
downloadgitbook-a65f888a77c48968087d23750e5fa4d55f2a8686.zip
gitbook-a65f888a77c48968087d23750e5fa4d55f2a8686.tar.gz
gitbook-a65f888a77c48968087d23750e5fa4d55f2a8686.tar.bz2
Start moving template and conrefs on Output
Diffstat (limited to 'lib/utils/git.js')
-rw-r--r--lib/utils/git.js17
1 files changed, 15 insertions, 2 deletions
diff --git a/lib/utils/git.js b/lib/utils/git.js
index baf0fab..fc75ee3 100644
--- a/lib/utils/git.js
+++ b/lib/utils/git.js
@@ -6,11 +6,12 @@ var URI = require('urijs');
var pathUtil = require('./path');
var Promise = require('./promise');
var command = require('./command');
+var fs = require('./fs');
var GIT_PREFIX = 'git+';
function Git(tmpDir) {
- this.tmpDir = tmpDir;
+ this.tmpDir;
this.cloned = {};
}
@@ -19,11 +20,23 @@ Git.prototype.repoID = function(host, ref) {
return crc.crc32(host+'#'+(ref || '')).toString(16);
};
+// Allocate a temporary folder for cloning repos in it
+Git.prototype.allocateDir = function() {
+ var that = this;
+
+ if (this.tmpDir) return Promise();
+
+ return fs.tmpDir()
+ .then(function(dir) {
+ that.tmpDir = dir;
+ });
+};
+
// Clone a git repository if non existant
Git.prototype.clone = function(host, ref) {
var that = this;
- return Promise()
+ return this.allocateDir()
// Return or clone the git repo
.then(function() {