diff --git a/lib/github-download.js b/lib/github-download.js index 1a821d5..6030869 100644 --- a/lib/github-download.js +++ b/lib/github-download.js @@ -1,11 +1,11 @@ var EventEmitter = require('events').EventEmitter - , vcsurl = require('vcsurl') - , request = require('request') - , path = require('path') - , fs = require('fs-extra') - , AdmZip = require('adm-zip') - , util = require('util') - , cwd = process.cwd() + , vcsurl = require('vcsurl') + , request = require('request') + , path = require('path') + , fs = require('fs-extra') + , AdmZip = require('adm-zip') + , util = require('util') + , cwd = process.cwd() function GithubDownloader (user, repo, ref, dir) { this.user = user @@ -19,7 +19,7 @@ util.inherits(GithubDownloader, EventEmitter) GithubDownloader.prototype.start = function() { - var _this = this + var _this = this , initialUrl = 'https://api.github.com/repos/' + this.user + '/' + this.repo + '/contents/' , initialUrlRef = this.ref ? '?ref=' + this.ref : '' , rawUrl = 'https://raw.github.com/' + this.user + '/' + this.repo + '/' + this.ref + '/' @@ -131,8 +131,8 @@ function downloadZip() { //fs.createReadStream(zipFile).pipe(unzip.Extract({path: tmpdir})).on('close', function() { extractZip.call(_this, zipFile, tmpdir, function() { var oldPath = path.join(tmpdir, zipBaseDir) - //console.log(oldPath) - fs.rename(oldPath, _this.dir, function(err) { + // console.log(oldPath, _this.dir); + fs.mv(oldPath, _this.dir, function(err) { if (err) _this.emit('error', err) fs.remove(tmpdir, function(err) { if (err) _this.emit('error', err) @@ -140,9 +140,9 @@ function downloadZip() { }) }) }) - }) + }) }) - + } function generateTempDir () { @@ -154,7 +154,7 @@ function extractZip (zipFile, outputDir, callback) { , entries = zip.getEntries() , pending = entries.length , _this = this - + function checkDone (err) { if (err) _this.emit('error', err) pending -= 1 diff --git a/package.json b/package.json index 8a8cd68..20c5379 100644 --- a/package.json +++ b/package.json @@ -25,10 +25,10 @@ } ], "dependencies": { - "request": "~2.12.0", - "vcsurl": "~0.1.0", "adm-zip": "~0.4.3", - "fs-extra": "^0.9.1" + "fs-extra": "^0.9.1", + "request": "~2.12.0", + "vcsurl": "~0.1.0" }, "devDependencies": { "testutil": "~0.5.0",