@ps-aux/nodebup 0.9.9 → 0.9.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,31 +19,46 @@ var _path = _interopRequireDefault(require("path"));
19
19
 
20
20
  var _promises = _interopRequireDefault(require("stream/promises"));
21
21
 
22
- var _dec, _class;
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 srcDir = dirPath.str();
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`, srcDir, dst);
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 z = new _Zipper.Zipper();
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');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ps-aux/nodebup",
3
- "version": "0.9.9",
3
+ "version": "0.9.10",
4
4
  "description": "",
5
5
  "module": "lib/index.js",
6
6
  "main": "lib/index.js",