bare-fs 4.4.7 → 4.4.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 (2) hide show
  1. package/index.js +9 -5
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -219,10 +219,10 @@ async function access(filepath, mode = constants.F_OK, cb) {
219
219
  }
220
220
 
221
221
  function accessSync(filepath, mode = constants.F_OK) {
222
- using req = FileRequest.borrow()
223
-
224
222
  filepath = toNamespacedPath(filepath)
225
223
 
224
+ using req = FileRequest.borrow()
225
+
226
226
  try {
227
227
  binding.accessSync(req.handle, filepath, mode)
228
228
  } catch (e) {
@@ -742,7 +742,9 @@ async function mkdir(filepath, opts, cb) {
742
742
  try {
743
743
  await mkdir(filepath, { mode })
744
744
  } catch (err) {
745
- if (err.code === 'ENOENT' || !(await stat(filepath)).isDirectory()) {
745
+ if (err.code !== 'ENOENT') {
746
+ if (!(await stat(filepath)).isDirectory()) throw err
747
+ } else {
746
748
  while (filepath.endsWith(path.sep)) filepath = filepath.slice(0, -1)
747
749
  const i = filepath.lastIndexOf(path.sep)
748
750
  if (i <= 0) throw err
@@ -793,7 +795,9 @@ function mkdirSync(filepath, opts) {
793
795
  try {
794
796
  mkdirSync(filepath, { mode })
795
797
  } catch (err) {
796
- if (err.code === 'ENOENT' || !statSync(filepath).isDirectory()) {
798
+ if (err.code !== 'ENOENT') {
799
+ if (!statSync(filepath).isDirectory()) throw err
800
+ } else {
797
801
  while (filepath.endsWith(path.sep)) filepath = filepath.slice(0, -1)
798
802
  const i = filepath.lastIndexOf(path.sep)
799
803
  if (i <= 0) throw err
@@ -1933,7 +1937,7 @@ class FileReadStream extends Readable {
1933
1937
  err = e
1934
1938
  }
1935
1939
 
1936
- if (err) return cb(err)
1940
+ if (err) return this.destroy(err)
1937
1941
 
1938
1942
  if (len === 0) return this.push(null)
1939
1943
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-fs",
3
- "version": "4.4.7",
3
+ "version": "4.4.9",
4
4
  "description": "Native file system operations for Javascript",
5
5
  "exports": {
6
6
  "./package": "./package.json",