mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-18 00:47:01 +00:00
feature(fstream) rm main
This commit is contained in:
parent
377726fa0a
commit
d7e3e55445
1 changed files with 18 additions and 18 deletions
|
|
@ -1,23 +1,13 @@
|
|||
(function () {
|
||||
'use strict';
|
||||
|
||||
if (!global.cloudcmd)
|
||||
return console.log(
|
||||
'# fstream.js' + '\n' +
|
||||
'# -----------' + '\n' +
|
||||
'# Module is part of Cloud Commander,' + '\n' +
|
||||
'# used for work with files.' + '\n' +
|
||||
'# http://cloudcmd.io' + '\n');
|
||||
var DIR = '../',
|
||||
Util = require(DIR + 'util'),
|
||||
fstream = tryRequire('fstream'),
|
||||
tar = tryRequire('tar');
|
||||
|
||||
var main = global.cloudcmd.main,
|
||||
fstream = main.require('fstream'),
|
||||
tar = main.require('tar');
|
||||
|
||||
|
||||
exports.pack = packDir;
|
||||
|
||||
function packDir(path) {
|
||||
var dirStream, tarStream, ret;
|
||||
exports.pack = function (path) {
|
||||
var dirStream, tarStream;
|
||||
|
||||
if (tar && fstream) {
|
||||
dirStream = fstream.Reader({
|
||||
|
|
@ -27,10 +17,20 @@
|
|||
|
||||
tarStream = tar.Pack({});
|
||||
|
||||
ret = dirStream.pipe(tarStream);
|
||||
dirStream = dirStream.pipe(tarStream);
|
||||
}
|
||||
|
||||
return ret;
|
||||
return dirStream;
|
||||
};
|
||||
|
||||
function tryRequire(name) {
|
||||
var module;
|
||||
|
||||
Util.exec.try(function() {
|
||||
module = require(name);
|
||||
});
|
||||
|
||||
return module;
|
||||
}
|
||||
|
||||
})();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue