mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-08-02 20:53:02 +00:00
feature(packer) packer -> jag
This commit is contained in:
parent
18f10740d8
commit
86db4b273e
4 changed files with 3 additions and 90 deletions
|
|
@ -1,88 +0,0 @@
|
|||
(function() {
|
||||
'use strict';
|
||||
|
||||
var DIR = './',
|
||||
DIR_LIB = DIR + '../',
|
||||
|
||||
path = require('path'),
|
||||
fs = require('fs'),
|
||||
zlib = require('zlib'),
|
||||
|
||||
tar = require('tar'),
|
||||
fstream = require('fstream'),
|
||||
|
||||
pipe = require('pipe-io'),
|
||||
files = require('files-io'),
|
||||
|
||||
Util = require(DIR_LIB + 'util');
|
||||
|
||||
exports.pack = function(from, to, callback) {
|
||||
isDir(from, function(is) {
|
||||
var dir, name,
|
||||
|
||||
optionsDir = { path: from, type: 'Directory' },
|
||||
optionsTar = { noProprietary: true },
|
||||
|
||||
streamDir,
|
||||
streamTar,
|
||||
streamZip = zlib.createGzip(),
|
||||
streamFile,
|
||||
|
||||
isStr = Util.type.string(to),
|
||||
options = {
|
||||
gzip: true
|
||||
};
|
||||
|
||||
if (!is) {
|
||||
files.pipe(from, to, options, callback);
|
||||
} else {
|
||||
streamDir = fstream.Reader(optionsDir);
|
||||
streamTar = tar.Pack(optionsTar);
|
||||
|
||||
if (!isStr) {
|
||||
streamFile = to;
|
||||
} else {
|
||||
dir = path.dirname(to);
|
||||
name = path.basename(to, '.gz');
|
||||
to = dir + path.sep + name + '.tar.gz';
|
||||
|
||||
streamFile = fs.createWriteStream(to);
|
||||
}
|
||||
|
||||
pipe([
|
||||
streamDir,
|
||||
streamTar,
|
||||
streamZip,
|
||||
streamFile
|
||||
], callback);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
exports.unpack = function(from, to, callback) {
|
||||
var write,
|
||||
isTarGz = /\.tar\.gz$/.test(from),
|
||||
|
||||
options = {
|
||||
gunzip : true
|
||||
};
|
||||
|
||||
if (isTarGz)
|
||||
write = tar.Extract({ path: to });
|
||||
else
|
||||
write = to;
|
||||
|
||||
files.pipe(from, write, options, callback);
|
||||
};
|
||||
|
||||
function isDir(name, callback) {
|
||||
fs.stat(name, function(error, stat) {
|
||||
var isDir;
|
||||
|
||||
if (!error)
|
||||
isDir = stat.isDirectory();
|
||||
|
||||
callback(isDir);
|
||||
});
|
||||
}
|
||||
})();
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
markdown = require(DIR + 'rest/markdown'),
|
||||
|
||||
github = require(DIR + 'github'),
|
||||
packer = require(DIR + 'packer'),
|
||||
packer = require('jag'),
|
||||
|
||||
tryRequire = require('./tryRequire'),
|
||||
tryOptions = {log: true, exit: true},
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
check = require('checkup'),
|
||||
exec = require('execon'),
|
||||
|
||||
packer = require(DIR_SERVER + 'packer'),
|
||||
packer = require('jag'),
|
||||
|
||||
tryRequire = require(DIR_SERVER + 'tryRequire'),
|
||||
tryOptions = {log: true, exit: true},
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
"flop": "~1.0.25",
|
||||
"fstream": "~1.0.2",
|
||||
"http-auth": "~2.2.3",
|
||||
"jag": "~1.0.0",
|
||||
"join-io": "~1.3.0",
|
||||
"js-beautify": "~1.5.4",
|
||||
"marked": "~0.3.2",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue