@ezs/basics 2.5.4 → 2.5.6

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.
package/README.md CHANGED
@@ -552,6 +552,7 @@ Take all recevied objects and build a tar file
552
552
  - `location` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Location path to store files in the tarball (optional, default `data`)
553
553
  - `json` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Convert to JSON the content of each chunk (optional, default `true`)
554
554
  - `extension` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Choose extension fo each file (optional, default `json`)
555
+ - `additionalFile` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Path to an additional file that will be add to tarball
555
556
  - `compress` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Enable gzip compression (optional, default `false`)
556
557
 
557
558
  ### TARExtract
package/lib/csv-parse.js CHANGED
@@ -20,9 +20,9 @@ function CSVParse(data, feed) {
20
20
  this.whenFinish = feed.flow(this.input);
21
21
  }
22
22
  if (this.isLast()) {
23
- this.decoder.end();
23
+ (0, _streamWrite.default)(this.input, this.decoder.end(), () => this.input.end());
24
24
  this.whenFinish.finally(() => feed.close());
25
- return this.input.end();
25
+ return;
26
26
  }
27
27
  (0, _streamWrite.default)(this.input, Buffer.isBuffer(data) ? this.decoder.write(data) : data, () => feed.end());
28
28
  }
package/lib/tar-dump.js CHANGED
@@ -4,10 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = TARDump;
7
+ var _path = require("path");
8
+ var _util = require("util");
9
+ var _fs = require("fs");
7
10
  var _tarStream = _interopRequireDefault(require("tar-stream"));
8
11
  var _zlib = require("zlib");
9
12
  var _lodash = _interopRequireDefault(require("lodash.merge"));
10
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+ // Avoid importing from fs/promise to be compatible with node 12
15
+ const readFilePromise = (0, _util.promisify)(_fs.readFile);
11
16
  const eol = '\n';
12
17
 
13
18
  /**
@@ -23,6 +28,7 @@ const eol = '\n';
23
28
  * @param {String} [location=data] Location path to store files in the tarball
24
29
  * @param {String} [json=true] Convert to JSON the content of each chunk
25
30
  * @param {String} [extension=json] Choose extension fo each file
31
+ * @param {String} [additionalFile] Path to an additional file that will be add to tarball
26
32
  * @param {Boolean} [compress=false] Enable gzip compression
27
33
  */
28
34
  function TARDump(data, feed) {
@@ -46,7 +52,10 @@ function TARDump(data, feed) {
46
52
  this.pack.entry({
47
53
  name: 'manifest.json'
48
54
  }, JSON.stringify(manifest, null, ' '));
49
- this.pack.finalize();
55
+ const additionalFiles = [].concat(this.getParam('additionalFile')).filter(Boolean).map(filename => this.ezs.getPath().map(dir => (0, _path.resolve)(dir, filename)).filter(Boolean).shift()).filter(Boolean).map(fullfilename => readFilePromise(fullfilename).then(fileContent => this.pack.entry({
56
+ name: (0, _path.basename)(fullfilename)
57
+ }, fileContent)));
58
+ Promise.all(additionalFiles).catch(e => feed.stop(e)).finally(() => this.pack.finalize());
50
59
  return;
51
60
  }
52
61
  const json = this.getParam('json', true);
package/lib/txt-parse.js CHANGED
@@ -8,12 +8,16 @@ var _string_decoder = require("string_decoder");
8
8
  function TXTParse(data, feed) {
9
9
  if (!this.decoder) {
10
10
  this.decoder = new _string_decoder.StringDecoder('utf8');
11
+ this.remainder = '';
12
+ this.counter = 0;
11
13
  }
12
14
  if (this.isLast()) {
13
- this.decoder.end();
15
+ this.remainder += this.decoder.end();
16
+ if (this.remainder && this.counter > 1) {
17
+ feed.write(this.remainder);
18
+ }
14
19
  return feed.end();
15
20
  }
16
- this.remainder = this.remainder || '';
17
21
  let separator;
18
22
  try {
19
23
  const val = '"'.concat(this.getParam('separator', '\n')).concat('"');
@@ -34,6 +38,7 @@ function TXTParse(data, feed) {
34
38
  lines.forEach(line => {
35
39
  feed.write(line);
36
40
  });
41
+ this.counter += lines.length;
37
42
  feed.end();
38
43
  }
39
44
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ezs/basics",
3
3
  "description": "Basics statements for EZS",
4
- "version": "2.5.4",
4
+ "version": "2.5.6",
5
5
  "author": "Nicolas Thouvenin <nthouvenin@gmail.com>",
6
6
  "bugs": "https://github.com/Inist-CNRS/ezs/issues",
7
7
  "dependencies": {
@@ -41,7 +41,7 @@
41
41
  "directories": {
42
42
  "test": "test"
43
43
  },
44
- "gitHead": "722a99ed17ffc2ae86b91aeaf09b5126b164191b",
44
+ "gitHead": "2b6b66d47ce0e57ebadfe846c76e0990a992977d",
45
45
  "homepage": "https://github.com/Inist-CNRS/ezs/tree/master/packages/basics#readme",
46
46
  "keywords": [
47
47
  "ezs"