summaryrefslogtreecommitdiffstats
path: root/lib/utils
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2015-11-25 10:08:24 +0100
committerSamy Pessé <samypesse@gmail.com>2015-11-25 10:08:24 +0100
commit98da83a5521dc4cf0e9ce50bfe92f9172475b559 (patch)
treec44877ac1b41059006a1e80c532b2ddafab702a8 /lib/utils
parent5344a30a3bd540c2569d34c2e3e941e057b8150d (diff)
downloadgitbook-98da83a5521dc4cf0e9ce50bfe92f9172475b559.zip
gitbook-98da83a5521dc4cf0e9ce50bfe92f9172475b559.tar.gz
gitbook-98da83a5521dc4cf0e9ce50bfe92f9172475b559.tar.bz2
Fix urijs dependency on linux
Diffstat (limited to 'lib/utils')
-rw-r--r--lib/utils/git.js38
1 files changed, 19 insertions, 19 deletions
diff --git a/lib/utils/git.js b/lib/utils/git.js
index e93c8f2..72c8818 100644
--- a/lib/utils/git.js
+++ b/lib/utils/git.js
@@ -1,14 +1,14 @@
-var Q = require("q");
-var _ = require("lodash");
-var path = require("path");
-var crc = require("crc");
-var exec = Q.denodeify(require("child_process").exec);
-var URI = require("URIjs");
-var pathUtil = require("./path");
+var Q = require('q');
+var _ = require('lodash');
+var path = require('path');
+var crc = require('crc');
+var exec = Q.denodeify(require('child_process').exec);
+var URI = require('urijs');
+var pathUtil = require('./path');
-var fs = require("./fs");
+var fs = require('./fs');
-var GIT_PREFIX = "git+";
+var GIT_PREFIX = 'git+';
var GIT_TMP = null;
@@ -30,20 +30,20 @@ function parseGitUrl(giturl) {
giturl = giturl.slice(GIT_PREFIX.length);
uri = new URI(giturl);
- ref = uri.fragment() || "master";
+ ref = uri.fragment() || 'master';
uri.fragment(null);
// Extract file inside the repo (after the .git)
- fileParts =uri.path().split(".git");
- filepath = fileParts.length > 1? fileParts.slice(1).join(".git") : "";
- if (filepath[0] == "/") filepath = filepath.slice(1);
+ fileParts =uri.path().split('.git');
+ filepath = fileParts.length > 1? fileParts.slice(1).join('.git') : '';
+ if (filepath[0] == '/') filepath = filepath.slice(1);
// Recreate pathname without the real filename
- uri.path(_.first(fileParts)+".git");
+ uri.path(_.first(fileParts)+'.git');
return {
host: uri.toString(),
- ref: ref || "master",
+ ref: ref || 'master',
filepath: filepath
};
}
@@ -52,7 +52,7 @@ function parseGitUrl(giturl) {
function cloneGitRepo(host, ref) {
var isBranch = false;
- ref = ref || "master";
+ ref = ref || 'master';
if (!validateSha(ref)) isBranch = true;
return Q()
@@ -69,7 +69,7 @@ function cloneGitRepo(host, ref) {
// Return or clone the git repo
.then(function() {
// Unique ID for repo/ref combinaison
- var repoId = crc.crc32(host+"#"+ref).toString(16);
+ var repoId = crc.crc32(host+'#'+ref).toString(16);
// Absolute path to the folder
var repoPath = path.resolve(GIT_TMP, repoId);
@@ -79,9 +79,9 @@ function cloneGitRepo(host, ref) {
if (doExists) return;
// Clone repo
- return exec("git clone "+host+" "+repoPath)
+ return exec('git clone '+host+' '+repoPath)
.then(function() {
- return exec("git checkout "+ref, { cwd: repoPath });
+ return exec('git checkout '+ref, { cwd: repoPath });
});
})
.thenResolve(repoPath);