@ps-aux/nodebup 0.9.9 → 0.9.10
Sign up to get free protection for your applications and to get access to all the features.
@@ -19,31 +19,46 @@ var _path = _interopRequireDefault(require("path"));
|
|
19
19
|
|
20
20
|
var _promises = _interopRequireDefault(require("stream/promises"));
|
21
21
|
|
22
|
-
var
|
22
|
+
var _Shell = require("../shell/Shell");
|
23
|
+
|
24
|
+
var _dec, _dec2, _dec3, _class;
|
23
25
|
|
24
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
25
27
|
|
26
28
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
27
29
|
|
28
|
-
let Zipper = (_dec = (0, _inversify.injectable)(), _dec(_class = class Zipper {
|
29
|
-
constructor() {
|
30
|
+
let Zipper = (_dec = (0, _inversify.injectable)(), _dec2 = Reflect.metadata("design:type", Function), _dec3 = Reflect.metadata("design:paramtypes", [typeof _Shell.Shell === "undefined" ? Object : _Shell.Shell]), _dec(_class = _dec2(_class = _dec3(_class = class Zipper {
|
31
|
+
constructor(sh) {
|
32
|
+
this.sh = sh;
|
33
|
+
|
30
34
|
_defineProperty(this, "log", (0, _logging.classObjLog)(this));
|
31
35
|
|
32
36
|
_defineProperty(this, "zipDir", async (dirPath, to) => {
|
33
|
-
const
|
37
|
+
const src = dirPath.str();
|
34
38
|
const dst = to.str();
|
35
39
|
|
36
40
|
const dstDir = _path.default.dirname(dst);
|
37
41
|
|
38
|
-
this.log.trace(`Zipping %s to %s`,
|
39
|
-
const zip = new _jszip.default();
|
40
|
-
buildZipFromDirectory(srcDir, zip);
|
41
|
-
const r = await zip.generateNodeStream();
|
42
|
+
this.log.trace(`Zipping %s to %s`, src, dst);
|
42
43
|
|
43
44
|
if (!_nodeFs.default.existsSync(dstDir)) {
|
44
45
|
_nodeFs.default.mkdirSync(dstDir);
|
45
46
|
}
|
46
47
|
|
48
|
+
await this.doDirZipInShell(src, dst);
|
49
|
+
});
|
50
|
+
|
51
|
+
_defineProperty(this, "doDirZipInShell", async (src, dst) => {
|
52
|
+
await this.sh.exec(`zip ${dst} -r .`, {
|
53
|
+
cwd: src
|
54
|
+
});
|
55
|
+
});
|
56
|
+
|
57
|
+
_defineProperty(this, "doDirZipInNodeJs", async (src, dst) => {
|
58
|
+
const zip = new _jszip.default();
|
59
|
+
buildZipFromDirectory(src, zip);
|
60
|
+
const r = await zip.generateNodeStream();
|
61
|
+
|
47
62
|
const ws = _nodeFs.default.createWriteStream(dst);
|
48
63
|
|
49
64
|
await _promises.default.pipeline(r, ws);
|
@@ -68,7 +83,7 @@ let Zipper = (_dec = (0, _inversify.injectable)(), _dec(_class = class Zipper {
|
|
68
83
|
});
|
69
84
|
}
|
70
85
|
|
71
|
-
}) || _class);
|
86
|
+
}) || _class) || _class) || _class);
|
72
87
|
exports.Zipper = Zipper;
|
73
88
|
|
74
89
|
const buildZipFromDirectory = (dir, zip, root = dir) => {
|
@@ -8,12 +8,15 @@ var _testHelper = require("../../../test/testHelper");
|
|
8
8
|
|
9
9
|
var _test = require("../../../test");
|
10
10
|
|
11
|
+
var _Shell = require("../shell/Shell");
|
12
|
+
|
11
13
|
describe('zip', () => {
|
12
14
|
afterEach(() => {
|
13
15
|
(0, _testHelper.cleanTestDataDir)();
|
14
16
|
});
|
15
17
|
it('zip and unzip', async () => {
|
16
|
-
const
|
18
|
+
const sh = new _Shell.Shell();
|
19
|
+
const z = new _Zipper.Zipper(sh);
|
17
20
|
const out = (0, _test.testdataDirPath)('out.zip');
|
18
21
|
|
19
22
|
const dir = _Path.AbsPath.from(__dirname).resolve('../../../test/foo');
|