bare-module 1.11.2 → 1.11.4

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/binding.c +14 -5
  2. package/index.js +1 -0
  3. package/package.json +1 -1
package/binding.c CHANGED
@@ -437,12 +437,12 @@ bare_module_exists (js_env_t *env, js_callback_info_t *info) {
437
437
 
438
438
  uv_stat_t *st = req.result < 0 ? NULL : req.ptr;
439
439
 
440
- uv_fs_req_cleanup(&req);
441
-
442
440
  js_value_t *result;
443
441
  err = js_get_boolean(env, st && st->st_mode & S_IFREG, &result);
444
442
  assert(err == 0);
445
443
 
444
+ uv_fs_req_cleanup(&req);
445
+
446
446
  return result;
447
447
  }
448
448
 
@@ -469,9 +469,12 @@ bare_module_realpath (js_env_t *env, js_callback_info_t *info) {
469
469
  uv_fs_t req;
470
470
  uv_fs_realpath(loop, &req, (char *) path, NULL);
471
471
 
472
- if (req.result < 0) {
473
- js_throw_error(env, uv_err_name(err), uv_strerror(err));
474
- return NULL;
472
+ int res = req.result;
473
+
474
+ if (res < 0) {
475
+ uv_fs_req_cleanup(&req);
476
+ err = res;
477
+ goto err;
475
478
  }
476
479
 
477
480
  js_value_t *result;
@@ -481,6 +484,11 @@ bare_module_realpath (js_env_t *env, js_callback_info_t *info) {
481
484
  uv_fs_req_cleanup(&req);
482
485
 
483
486
  return result;
487
+
488
+ err:
489
+ js_throw_error(env, uv_err_name(err), uv_strerror(err));
490
+
491
+ return NULL;
484
492
  }
485
493
 
486
494
  static js_value_t *
@@ -536,6 +544,7 @@ bare_module_read (js_env_t *env, js_callback_info_t *info) {
536
544
  if (res < 0) {
537
545
  uv_fs_close(loop, &req, fd, NULL);
538
546
  uv_fs_req_cleanup(&req);
547
+ err = res;
539
548
  goto err;
540
549
  }
541
550
 
package/index.js CHANGED
@@ -526,6 +526,7 @@ Module._protocols['file:'] = new Protocol({
526
526
  },
527
527
 
528
528
  postresolve (specifier) {
529
+ if (Module.isBuiltin(specifier)) return specifier
529
530
  return binding.realpath(specifier)
530
531
  },
531
532
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bare-module",
3
- "version": "1.11.2",
3
+ "version": "1.11.4",
4
4
  "description": "Module support for JavaScript",
5
5
  "main": "index.js",
6
6
  "files": [