Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CB-8154 Fix errors adding platforms or plugins
- Added utility function to unpack a package.tgz file (gzip + tar) - Use the new utility function when fetching plugins from the registry - Use the new utility function when downloading platforms from the registry - This compensates for the change in npm behaviour that no longer unpacks files that are added to the npm cached (change in 1.4.10) GitHub: close #130
- Loading branch information
Showing
3 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// commands for packing and unpacking tarballs | ||
// this file is used by lib/cache.js | ||
|
||
var events = require('../events'), | ||
fs = require("fs"), | ||
path = require("path"), | ||
Q = require('q'), | ||
tar = require("tar"), | ||
zlib = require("zlib"); | ||
|
||
exports.unpackTgz = unpackTgz; | ||
|
||
// Returns a promise for the path to the unpacked tarball (unzip + untar). | ||
function unpackTgz(package_tgz, unpackTarget) { | ||
return Q.promise(function(resolve, reject) { | ||
var extractOpts = { type: "Directory", path: unpackTarget, strip: 1 }; | ||
|
||
fs.createReadStream(package_tgz) | ||
.on("error", function (err) { | ||
events.emit('verbose', 'Unable to open tarball ' + package_tgz + ': ' + err); | ||
reject(err); | ||
}) | ||
.pipe(zlib.createUnzip()) | ||
.on("error", function (err) { | ||
events.emit('verbose', 'Error during unzip for ' + package_tgz + ': ' + err); | ||
reject(err); | ||
}) | ||
.pipe(tar.Extract(extractOpts)) | ||
.on('error', function(err) { | ||
events.emit('verbose', 'Error during untar for ' + package_tgz + ': ' + err); | ||
reject(err); | ||
}) | ||
.on("end", resolve); | ||
}) | ||
.then(function() { | ||
return unpackTarget; | ||
}); | ||
} |