read-data-file 2.0.6 → 2.0.9

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.
Files changed (3) hide show
  1. package/README.md +7 -0
  2. package/package.json +3 -3
  3. package/rdf.mjs +12 -5
package/README.md CHANGED
@@ -77,6 +77,13 @@ see [test/usage.js](test/usage.js)
77
77
  <!--#toc stop="scan" -->
78
78
 
79
79
 
80
+ Compatibility
81
+ -------------
82
+
83
+ * If you need ancient versions of Node.js (older than 14.x),
84
+ stay with `read-data-file` v2.x.
85
+
86
+
80
87
 
81
88
  Known issues
82
89
  ------------
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  { "name": "read-data-file",
2
- "version": "2.0.6",
2
+ "version": "2.0.9",
3
3
  "description": "Read data/config files in various formats (parsers list is configurable).",
4
4
  "keywords": [
5
5
  "read data file",
@@ -32,15 +32,15 @@
32
32
  "esmod-pmb": "^0.1.13",
33
33
  "getown": "^1.0.0",
34
34
  "if-fun": "^1.0.1",
35
- "ini": "^3.0.1",
35
+ "ini": "^2.0.0",
36
36
  "is-string": "^1.0.7",
37
37
  "json-parse-pmb": "^1.0.0",
38
38
  "json5": "^2.2.1",
39
39
  "map-assoc-core": "^0.1.3",
40
40
  "merge-options": "^3.0.4",
41
- "nofs": "^0.12.2",
42
41
  "p-each-series": "^2.2.0",
43
42
  "p-fatal": "^0.1.3",
43
+ "pify": "^5.0.0",
44
44
  "safeload-yaml-pmb": "^4.210519.0",
45
45
  "strip-bom": "^4.0.0",
46
46
  "toml": "^3.0.0",
package/rdf.mjs CHANGED
@@ -1,13 +1,14 @@
1
1
  // -*- coding: utf-8, tab-width: 2 -*-
2
2
 
3
3
  import pathLib from 'path';
4
+ import nodeFs from 'fs';
4
5
 
5
6
  import getOwn from 'getown';
6
7
  import ifFun from 'if-fun';
7
8
  import isStr from 'is-string';
8
9
  import mapObj from 'map-assoc-core';
9
10
  import mergeOpts from 'merge-options';
10
- import promisedFs from 'nofs';
11
+ import pify from 'pify';
11
12
  import stripBom from 'strip-bom';
12
13
 
13
14
  import cesonParser from 'ceson/parse.js';
@@ -93,7 +94,7 @@ const defaultImpl = {
93
94
  },
94
95
 
95
96
  async defaultReader(path) {
96
- const text = stripBom(await promisedFs.readFile(path,
97
+ const text = stripBom(await pify(nodeFs.readFile)(path,
97
98
  { encoding: 'UTF-8' }));
98
99
  return text;
99
100
  },
@@ -113,9 +114,15 @@ const defaultImpl = {
113
114
  const rop = this.findBestReaderAndParser(dotParts);
114
115
  if (!rop) { return this.unsupportedFext(realPath); }
115
116
  const { reader, parser } = rop;
116
- const content = await ifFun(reader, this.defaultReader)(realPath);
117
- const data = await ifFun(parser, identity)(content);
118
- return data;
117
+ try {
118
+ const content = await ifFun(reader, this.defaultReader)(realPath);
119
+ const data = await ifFun(parser, identity)(content);
120
+ return data;
121
+ } catch (err) {
122
+ err.dataFilePath = path;
123
+ err.message += ' — Error occurred while trying to read file ' + path;
124
+ throw err;
125
+ }
119
126
  },
120
127
 
121
128
  },