zip.js | |
---|---|
/*
* zip.js: Implementation of the repository pattern for remote zip files.
*
* (C) 2010, Nodejitsu Inc.
*
*/
var sys = require('sys'),
fs = require('fs'),
path = require('path'),
eyes = require('eyes'),
exec = require('child_process').exec,
RemoteFile = require('./remote-file').RemoteFile; | |
function Zip (app, options)@app {Object} The application to create the repository for@options {Object} Options to pass along to the repositoryConstructor function for the Zip repository. | var Zip = function (app, options) {
RemoteFile.call(this, app, options);
}; |
Inherit from the RemoteFile repository | sys.inherits(Zip, RemoteFile); |
function init (callback)@callback {function} Continuation to pass control back to when complete.Initializes this instance by checking the app, then installing
npm dependencies, then downloading files located in repository
to the target directory set on | Zip.prototype.init = function (callback) {
var self = this;
self.installDependencies(function (err, installed, packages) {
if (err) {
return callback(err);
}
self.fetch(function (err, packageFile) {
if (err) {
return callback(err);
}
var command = 'unzip -u ' + packageFile + ' -d ' + self.appDir;
exec(command, function (err, stdout, stderr) {
self.stat(function (err, exists) {
if (err) {
return callback(err);
}
var files = stdout.split('\n').splice(1).map(function (line) {
return line.slice(13);
});
callback(null, true, files, packages);
});
});
});
});
};
exports.Zip = Zip;
|