diff options
Diffstat (limited to 'lib/utils/git.js')
-rw-r--r-- | lib/utils/git.js | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/utils/git.js b/lib/utils/git.js index 52b1096..6884b83 100644 --- a/lib/utils/git.js +++ b/lib/utils/git.js @@ -1,4 +1,4 @@ -var _ = require('lodash'); +var is = require('is'); var path = require('path'); var crc = require('crc'); var URI = require('urijs'); @@ -69,7 +69,7 @@ Git.prototype.resolve = function(giturl) { if (this.resolveRoot(giturl)) return Promise(giturl); return Promise(null); } - if (_.isString(giturl)) giturl = Git.parseUrl(giturl); + if (is.string(giturl)) giturl = Git.parseUrl(giturl); if (!giturl) return Promise(null); // Clone or get from cache @@ -88,8 +88,10 @@ Git.prototype.resolveRoot = function(filepath) { // Extract first directory (is the repo id) relativeToGit = path.relative(this.tmpDir, filepath); - repoId = _.first(relativeToGit.split(path.sep)); - if (!repoId) return; + repoId = relativeToGit.split(path.sep)[0]; + if (!repoId) { + return; + } // Return an absolute file return path.resolve(this.tmpDir, repoId); @@ -114,10 +116,12 @@ Git.parseUrl = function(giturl) { // 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); + if (filepath[0] == '/') { + filepath = filepath.slice(1); + } // Recreate pathname without the real filename - uri.path(_.first(fileParts)+'.git'); + uri.path(fileParts[0] + '.git'); return { host: uri.toString(), |