bare-fs 2.1.5 → 2.2.1

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
@@ -38,6 +38,7 @@ fs.watch
38
38
  fs.write
39
39
  fs.writev
40
40
 
41
+ fs.appendFile
41
42
  fs.readFile
42
43
  fs.writeFile
43
44
 
@@ -46,7 +47,6 @@ fs.promises.chmod
46
47
  fs.promises.lstat
47
48
  fs.promises.mkdir
48
49
  fs.promises.opendir
49
- fs.promises.readFile
50
50
  fs.promises.readdir
51
51
  fs.promises.readlink
52
52
  fs.promises.realpath
@@ -56,6 +56,9 @@ fs.promises.stat
56
56
  fs.promises.symlink
57
57
  fs.promises.unlink
58
58
  fs.promises.watch
59
+
60
+ fs.promises.appendFile
61
+ fs.promises.readFile
59
62
  fs.promises.writeFile
60
63
 
61
64
  fs.createReadStream
@@ -82,6 +85,7 @@ fs.symlinkSync
82
85
  fs.unlinkSync
83
86
  fs.writeSync
84
87
 
88
+ fs.appendFileSync
85
89
  fs.readFileSync
86
90
  fs.writeFileSync
87
91
  ```
package/binding.c CHANGED
@@ -114,6 +114,10 @@ on_fs_stat_response (uv_fs_t *uv_req) {
114
114
  js_env_t *env = req->env;
115
115
 
116
116
  if (uv_req->result == 0) {
117
+ js_handle_scope_t *scope;
118
+ err = js_open_handle_scope(env, &scope);
119
+ assert(err == 0);
120
+
117
121
  js_value_t *data;
118
122
  err = js_get_reference_value(env, req->data, &data);
119
123
  assert(err == 0);
@@ -157,6 +161,9 @@ on_fs_stat_response (uv_fs_t *uv_req) {
157
161
  V(ctim)
158
162
  V(birthtim)
159
163
  #undef V
164
+
165
+ err = js_close_handle_scope(req->env, scope);
166
+ assert(err == 0);
160
167
  }
161
168
 
162
169
  on_fs_response(uv_req);
@@ -171,6 +178,10 @@ on_fs_realpath_response (uv_fs_t *uv_req) {
171
178
  js_env_t *env = req->env;
172
179
 
173
180
  if (uv_req->result == 0) {
181
+ js_handle_scope_t *scope;
182
+ err = js_open_handle_scope(env, &scope);
183
+ assert(err == 0);
184
+
174
185
  js_value_t *data;
175
186
  err = js_get_reference_value(env, req->data, &data);
176
187
  assert(err == 0);
@@ -180,6 +191,9 @@ on_fs_realpath_response (uv_fs_t *uv_req) {
180
191
  assert(err == 0);
181
192
 
182
193
  strncpy(path, uv_req->ptr, sizeof(bare_fs_path_t));
194
+
195
+ err = js_close_handle_scope(req->env, scope);
196
+ assert(err == 0);
183
197
  }
184
198
 
185
199
  on_fs_response(uv_req);
@@ -194,6 +208,10 @@ on_fs_readlink_response (uv_fs_t *uv_req) {
194
208
  js_env_t *env = req->env;
195
209
 
196
210
  if (uv_req->result == 0) {
211
+ js_handle_scope_t *scope;
212
+ err = js_open_handle_scope(env, &scope);
213
+ assert(err == 0);
214
+
197
215
  js_value_t *data;
198
216
  err = js_get_reference_value(env, req->data, &data);
199
217
  assert(err == 0);
@@ -203,6 +221,9 @@ on_fs_readlink_response (uv_fs_t *uv_req) {
203
221
  assert(err == 0);
204
222
 
205
223
  strncpy(path, uv_req->ptr, sizeof(bare_fs_path_t));
224
+
225
+ err = js_close_handle_scope(req->env, scope);
226
+ assert(err == 0);
206
227
  }
207
228
 
208
229
  on_fs_response(uv_req);
@@ -217,6 +238,10 @@ on_fs_opendir_response (uv_fs_t *uv_req) {
217
238
  js_env_t *env = req->env;
218
239
 
219
240
  if (uv_req->result == 0) {
241
+ js_handle_scope_t *scope;
242
+ err = js_open_handle_scope(env, &scope);
243
+ assert(err == 0);
244
+
220
245
  js_value_t *data;
221
246
  err = js_get_reference_value(env, req->data, &data);
222
247
  assert(err == 0);
@@ -226,6 +251,9 @@ on_fs_opendir_response (uv_fs_t *uv_req) {
226
251
  assert(err == 0);
227
252
 
228
253
  dir->dir = uv_req->ptr;
254
+
255
+ err = js_close_handle_scope(req->env, scope);
256
+ assert(err == 0);
229
257
  }
230
258
 
231
259
  on_fs_response(uv_req);
@@ -240,6 +268,10 @@ on_fs_readdir_response (uv_fs_t *uv_req) {
240
268
  js_env_t *env = req->env;
241
269
 
242
270
  if (uv_req->result > 0) {
271
+ js_handle_scope_t *scope;
272
+ err = js_open_handle_scope(env, &scope);
273
+ assert(err == 0);
274
+
243
275
  js_value_t *data;
244
276
  err = js_get_reference_value(env, req->data, &data);
245
277
  assert(err == 0);
@@ -275,6 +307,9 @@ on_fs_readdir_response (uv_fs_t *uv_req) {
275
307
  err = js_set_named_property(env, entry, "type", type);
276
308
  assert(err == 0);
277
309
  }
310
+
311
+ err = js_close_handle_scope(req->env, scope);
312
+ assert(err == 0);
278
313
  }
279
314
 
280
315
  on_fs_response(uv_req);
package/index.js CHANGED
@@ -1327,6 +1327,51 @@ function writeFileSync (filepath, data, opts) {
1327
1327
  }
1328
1328
  }
1329
1329
 
1330
+ function appendFile (filepath, data, opts, cb) {
1331
+ if (typeof filepath !== 'string') {
1332
+ throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')')
1333
+ }
1334
+
1335
+ if (typeof data !== 'string' && !Buffer.isBuffer(data) && !ArrayBuffer.isView(data)) {
1336
+ throw typeError('ERR_INVALID_ARG_TYPE', 'Data must be a string or buffer. Received type ' + (typeof data) + ' (' + data + ')')
1337
+ }
1338
+
1339
+ if (typeof opts === 'function') {
1340
+ cb = opts
1341
+ opts = {}
1342
+ } else if (typeof cb !== 'function') {
1343
+ throw typeError('ERR_INVALID_ARG_TYPE', 'Callback must be a function. Received type ' + (typeof cb) + ' (' + cb + ')')
1344
+ }
1345
+
1346
+ if (typeof opts === 'string') opts = { encoding: opts }
1347
+ else if (!opts) opts = {}
1348
+
1349
+ opts = { ...opts }
1350
+
1351
+ if (!opts.flags) opts.flag = 'a'
1352
+
1353
+ return writeFile(filepath, data, opts, cb)
1354
+ }
1355
+
1356
+ function appendFileSync (filepath, data, opts) {
1357
+ if (typeof filepath !== 'string') {
1358
+ throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')')
1359
+ }
1360
+
1361
+ if (typeof data !== 'string' && !Buffer.isBuffer(data) && !ArrayBuffer.isView(data)) {
1362
+ throw typeError('ERR_INVALID_ARG_TYPE', 'Data must be a string or buffer. Received type ' + (typeof data) + ' (' + data + ')')
1363
+ }
1364
+
1365
+ if (typeof opts === 'string') opts = { encoding: opts }
1366
+ else if (!opts) opts = {}
1367
+
1368
+ opts = { ...opts }
1369
+
1370
+ if (!opts.flags) opts.flag = 'a'
1371
+
1372
+ return writeFileSync(filepath, data, opts)
1373
+ }
1374
+
1330
1375
  function watch (filepath, opts, cb) {
1331
1376
  if (typeof filepath !== 'string') {
1332
1377
  throw typeError('ERR_INVALID_ARG_TYPE', 'Path must be a string. Received type ' + (typeof filepath) + ' (' + filepath + ')')
@@ -1783,6 +1828,7 @@ function typeError (code, message) {
1783
1828
  function noop () {}
1784
1829
 
1785
1830
  exports.access = access
1831
+ exports.appendFile = appendFile
1786
1832
  exports.chmod = chmod
1787
1833
  exports.close = close
1788
1834
  exports.exists = exists
@@ -1811,6 +1857,7 @@ exports.writeFile = writeFile
1811
1857
  exports.writev = writev
1812
1858
 
1813
1859
  exports.accessSync = accessSync
1860
+ exports.appendFileSync = appendFileSync
1814
1861
  exports.chmodSync = chmodSync
1815
1862
  exports.closeSync = closeSync
1816
1863
  exports.existsSync = existsSync
@@ -1835,6 +1882,7 @@ exports.writeFileSync = writeFileSync
1835
1882
  exports.writeSync = writeSync
1836
1883
 
1837
1884
  exports.promises.access = promisify(access)
1885
+ exports.promises.appendFile = promisify(appendFile)
1838
1886
  exports.promises.chmod = promisify(chmod)
1839
1887
  exports.promises.lstat = promisify(lstat)
1840
1888
  exports.promises.mkdir = promisify(mkdir)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-fs",
3
- "version": "2.1.5",
3
+ "version": "2.2.1",
4
4
  "description": "Native file system for Javascript",
5
5
  "main": "index.js",
6
6
  "files": [
Binary file
Binary file
Binary file
Binary file
Binary file