feature(rest) zip, unzip -> pack, unpack

This commit is contained in:
coderaiser 2014-11-01 04:12:42 -04:00
parent 2a6db8c64f
commit 7e28316a22
5 changed files with 22 additions and 22 deletions

View file

@ -15,7 +15,7 @@
Util = require(DIR_LIB + 'util'),
pipe = require(DIR + 'pipe');
exports.gzip = function(from, to, callback) {
exports.pack = function(from, to, callback) {
isDir(from, function(is) {
var options = {
gzip: true
@ -29,8 +29,8 @@
isStr = Util.type.string(to);
if (isStr) {
dir = path.dirname(to),
name = path.basename(to, '.zip');
dir = path.dirname(to);
name = path.basename(to);
to = dir + path.sep + name + '.tar.gz';
}
@ -39,7 +39,7 @@
});
};
exports.gunzip = function(from, to, callback) {
exports.unpack = function(from, to, callback) {
var write,
isStr = Util.type.string(from),
check = Util.checkExt,

View file

@ -23,7 +23,7 @@
github = require(DIR + 'github'),
flop = require(DIR + 'flop'),
pack = require(DIR + 'pack'),
packer = require(DIR + 'packer'),
mellow = require(DIR + 'mellow'),
ponse = require(DIR + 'ponse'),
pipe = require(DIR + 'pipe'),
@ -330,7 +330,7 @@
}
break;
case 'zip':
case 'pack':
if (!files.from) {
callback(body);
} else {
@ -339,18 +339,18 @@
if (files.to)
to = mellow.convertPath(files.to);
else
to = from + '.zip';
to = from + '.gz';
pack.gzip(from, to, function(error) {
packer.pack(from, to, function(error) {
var name = path.basename(files.from),
msg = formatMsg('zip', name);
msg = formatMsg('pack', name);
callback(error, msg);
});
}
break;
case 'unzip':
case 'unpack':
if (!files.from) {
callback(body);
} else {
@ -361,9 +361,9 @@
else
to = Util.rmStrOnce(files.from, ['.zip', '.tar.gz', '.gz']);
pack.gunzip(from, to, function(error) {
packer.unpack(from, to, function(error) {
var name = path.basename(files.from),
data = formatMsg('unzip', name);
data = formatMsg('unpack', name);
callback(error, data);
});

View file

@ -11,7 +11,7 @@
Util = require(DIR + 'util'),
flop = require(DIR_SERVER + 'flop'),
pack = require(DIR_SERVER + 'pack'),
packer = require(DIR_SERVER + 'packer'),
pipe = require(DIR_SERVER + 'pipe'),
patch = require('./patch');
@ -42,7 +42,7 @@
break;
case 'unzip':
pack.gunzip(readStream, name, onSave);
packer.unpack(readStream, name, onSave);
break;
case 'patch':