You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by fi...@apache.org on 2013/06/11 07:36:56 UTC
git commit: axed tar.gz in favour of isaacs tar module. first pass
the .gz into zlib, then the .tar into tar, and stuff works out.
Updated Branches:
refs/heads/lazy 859c147e0 -> b89019bf3
axed tar.gz in favour of isaacs tar module. first pass the .gz into zlib, then the .tar into tar, and stuff works out.
Project: http://git-wip-us.apache.org/repos/asf/cordova-cli/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-cli/commit/b89019bf
Tree: http://git-wip-us.apache.org/repos/asf/cordova-cli/tree/b89019bf
Diff: http://git-wip-us.apache.org/repos/asf/cordova-cli/diff/b89019bf
Branch: refs/heads/lazy
Commit: b89019bf30a02ae28a3d8e62df145b807e3ce39c
Parents: 859c147
Author: Fil Maj <ma...@gmail.com>
Authored: Mon Jun 10 22:36:46 2013 -0700
Committer: Fil Maj <ma...@gmail.com>
Committed: Mon Jun 10 22:36:46 2013 -0700
----------------------------------------------------------------------
package.json | 2 +-
src/lazy_load.js | 56 ++++++++++++++++++++++++++++++++-------------------
2 files changed, 36 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b89019bf/package.json
----------------------------------------------------------------------
diff --git a/package.json b/package.json
index 428d58b..8a37017 100644
--- a/package.json
+++ b/package.json
@@ -36,7 +36,7 @@
"glob":"3.2.x",
"follow-redirects":"0.0.x",
"prompt":"0.2.7",
- "tar.gz":"0.1.x",
+ "tar":"0.1.x",
"ripple-emulator":">=0.9.15",
"open": "0.0.3"
},
http://git-wip-us.apache.org/repos/asf/cordova-cli/blob/b89019bf/src/lazy_load.js
----------------------------------------------------------------------
diff --git a/src/lazy_load.js b/src/lazy_load.js
index 688e101..8094965 100644
--- a/src/lazy_load.js
+++ b/src/lazy_load.js
@@ -23,7 +23,8 @@ var path = require('path'),
events = require('./events'),
glob = require('glob'),
https = require('follow-redirects').https,
- targz = require('tar.gz'),
+ zlib = require('zlib'),
+ tar = require('tar'),
util = require('./util');
/**
@@ -61,28 +62,41 @@ module.exports = function lazy_load(platform, callback) {
// TODO: hook in end event
downloadfile.end();
events.emit('log', 'Download complete. Extracting...');
-
- new targz().extract(filename, util.libDirectory, function(err) {
- if (err) {
- if (callback) return callback(err);
- else throw err;
- } else {
- // rename the extracted dir to remove the trailing SHA
- glob(path.join(util.libDirectory, 'cordova-' + platform + '-' + util.cordovaTag + '-*'), function(err, entries) {
- if (err) {
- if (callback) return callback(err);
- else throw err;
- } else {
- var entry = entries[0];
- var final_dir = path.join(util.libDirectory, 'cordova-' + platform + '-' + util.cordovaTag);
- shell.mkdir(final_dir);
- shell.mv('-f', path.join(entry, (platform=='blackberry'?'blackberry10':''), '*'), final_dir);
- shell.rm('-rf', entry);
- if (callback) callback();
- }
+ var tar_path = path.join(util.libDirectory, 'cordova-' + platform + '-' + util.cordovaTag + '.tar');
+ var tarfile = fs.createWriteStream(tar_path);
+ tarfile.on('error', function(err) {
+ if (callback) callback(err);
+ else throw err;
+ });
+ tarfile.on('finish', function() {
+ shell.rm(filename);
+ fs.createReadStream(tar_path)
+ .pipe(tar.Extract({ path: util.libDirectory }))
+ .on("error", function (err) {
+ if (callback) callback(err);
+ else throw err;
+ })
+ .on("end", function () {
+ shell.rm(tar_path);
+ // rename the extracted dir to remove the trailing SHA
+ glob(path.join(util.libDirectory, 'cordova-' + platform + '-' + util.cordovaTag + '-*'), function(err, entries) {
+ if (err) {
+ if (callback) return callback(err);
+ else throw err;
+ } else {
+ var entry = entries[0];
+ var final_dir = path.join(util.libDirectory, 'cordova-' + platform + '-' + util.cordovaTag);
+ shell.mkdir(final_dir);
+ shell.mv('-f', path.join(entry, (platform=='blackberry'?'blackberry10':''), '*'), final_dir);
+ shell.rm('-rf', entry);
+ if (callback) callback();
+ }
+ });
});
- }
});
+ fs.createReadStream(filename)
+ .pipe(zlib.createUnzip())
+ .pipe(tarfile);
});
});
req.on('error', function(err) {