@photostructure/fs-metadata 0.4.0 → 0.5.0

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 (179) hide show
  1. package/C++_REVIEW_TODO.md +291 -0
  2. package/CHANGELOG.md +29 -1
  3. package/CLAUDE.md +169 -0
  4. package/CONTRIBUTING.md +25 -0
  5. package/coverage/base.css +224 -0
  6. package/coverage/block-navigation.js +87 -0
  7. package/coverage/favicon.png +0 -0
  8. package/coverage/index.html +131 -0
  9. package/coverage/lcov-report/base.css +224 -0
  10. package/coverage/lcov-report/block-navigation.js +87 -0
  11. package/coverage/lcov-report/favicon.png +0 -0
  12. package/coverage/lcov-report/index.html +131 -0
  13. package/coverage/lcov-report/prettify.css +1 -0
  14. package/coverage/lcov-report/prettify.js +2 -0
  15. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  16. package/coverage/lcov-report/sorter.js +196 -0
  17. package/coverage/lcov-report/src/array.ts.html +217 -0
  18. package/coverage/lcov-report/src/async.ts.html +547 -0
  19. package/coverage/lcov-report/src/debuglog.ts.html +187 -0
  20. package/coverage/lcov-report/src/defer.ts.html +175 -0
  21. package/coverage/lcov-report/src/dirname.ts.html +124 -0
  22. package/coverage/lcov-report/src/error.ts.html +322 -0
  23. package/coverage/lcov-report/src/fs.ts.html +316 -0
  24. package/coverage/lcov-report/src/glob.ts.html +472 -0
  25. package/coverage/lcov-report/src/hidden.ts.html +724 -0
  26. package/coverage/lcov-report/src/index.html +521 -0
  27. package/coverage/lcov-report/src/index.ts.html +676 -0
  28. package/coverage/lcov-report/src/linux/dev_disk.ts.html +316 -0
  29. package/coverage/lcov-report/src/linux/index.html +146 -0
  30. package/coverage/lcov-report/src/linux/mount_points.ts.html +364 -0
  31. package/coverage/lcov-report/src/linux/mtab.ts.html +493 -0
  32. package/coverage/lcov-report/src/mount_point.ts.html +106 -0
  33. package/coverage/lcov-report/src/number.ts.html +148 -0
  34. package/coverage/lcov-report/src/object.ts.html +265 -0
  35. package/coverage/lcov-report/src/options.ts.html +475 -0
  36. package/coverage/lcov-report/src/path.ts.html +268 -0
  37. package/coverage/lcov-report/src/platform.ts.html +112 -0
  38. package/coverage/lcov-report/src/random.ts.html +205 -0
  39. package/coverage/lcov-report/src/remote_info.ts.html +553 -0
  40. package/coverage/lcov-report/src/stack_path.ts.html +298 -0
  41. package/coverage/lcov-report/src/string.ts.html +382 -0
  42. package/coverage/lcov-report/src/string_enum.ts.html +208 -0
  43. package/coverage/lcov-report/src/system_volume.ts.html +301 -0
  44. package/coverage/lcov-report/src/unc.ts.html +274 -0
  45. package/coverage/lcov-report/src/units.ts.html +274 -0
  46. package/coverage/lcov-report/src/uuid.ts.html +157 -0
  47. package/coverage/lcov-report/src/volume_health_status.ts.html +259 -0
  48. package/coverage/lcov-report/src/volume_metadata.ts.html +787 -0
  49. package/coverage/lcov-report/src/volume_mount_points.ts.html +388 -0
  50. package/coverage/lcov.info +3581 -0
  51. package/coverage/prettify.css +1 -0
  52. package/coverage/prettify.js +2 -0
  53. package/coverage/sort-arrow-sprite.png +0 -0
  54. package/coverage/sorter.js +196 -0
  55. package/coverage/src/array.ts.html +217 -0
  56. package/coverage/src/async.ts.html +547 -0
  57. package/coverage/src/debuglog.ts.html +187 -0
  58. package/coverage/src/defer.ts.html +175 -0
  59. package/coverage/src/dirname.ts.html +124 -0
  60. package/coverage/src/error.ts.html +322 -0
  61. package/coverage/src/fs.ts.html +316 -0
  62. package/coverage/src/glob.ts.html +472 -0
  63. package/coverage/src/hidden.ts.html +724 -0
  64. package/coverage/src/index.html +521 -0
  65. package/coverage/src/index.ts.html +676 -0
  66. package/coverage/src/linux/dev_disk.ts.html +316 -0
  67. package/coverage/src/linux/index.html +146 -0
  68. package/coverage/src/linux/mount_points.ts.html +364 -0
  69. package/coverage/src/linux/mtab.ts.html +493 -0
  70. package/coverage/src/mount_point.ts.html +106 -0
  71. package/coverage/src/number.ts.html +148 -0
  72. package/coverage/src/object.ts.html +265 -0
  73. package/coverage/src/options.ts.html +475 -0
  74. package/coverage/src/path.ts.html +268 -0
  75. package/coverage/src/platform.ts.html +112 -0
  76. package/coverage/src/random.ts.html +205 -0
  77. package/coverage/src/remote_info.ts.html +553 -0
  78. package/coverage/src/stack_path.ts.html +298 -0
  79. package/coverage/src/string.ts.html +382 -0
  80. package/coverage/src/string_enum.ts.html +208 -0
  81. package/coverage/src/system_volume.ts.html +301 -0
  82. package/coverage/src/unc.ts.html +274 -0
  83. package/coverage/src/units.ts.html +274 -0
  84. package/coverage/src/uuid.ts.html +157 -0
  85. package/coverage/src/volume_health_status.ts.html +259 -0
  86. package/coverage/src/volume_metadata.ts.html +787 -0
  87. package/coverage/src/volume_mount_points.ts.html +388 -0
  88. package/jest.config.cjs +67 -6
  89. package/package.json +51 -41
  90. package/prebuilds/linux-x64/@photostructure+fs-metadata.glibc.node +0 -0
  91. package/scripts/check-memory.mjs +243 -0
  92. package/scripts/clang-tidy.mjs +73 -0
  93. package/scripts/is-platform.mjs +12 -0
  94. package/scripts/post-build.mjs +21 -0
  95. package/scripts/run-asan.sh +92 -0
  96. package/scripts/valgrind-test.mjs +83 -0
  97. package/scripts/valgrind.sh +70 -0
  98. package/src/async.ts +3 -3
  99. package/src/binding.cpp +3 -3
  100. package/src/error.ts +3 -3
  101. package/src/fs.ts +1 -1
  102. package/src/glob.ts +2 -2
  103. package/src/hidden.ts +6 -6
  104. package/src/index.ts +19 -23
  105. package/src/linux/blkid_cache.cpp +15 -12
  106. package/src/linux/dev_disk.ts +2 -2
  107. package/src/linux/gio_mount_points.cpp +7 -7
  108. package/src/linux/gio_utils.cpp +19 -8
  109. package/src/linux/gio_volume_metadata.cpp +15 -15
  110. package/src/linux/mount_points.ts +9 -9
  111. package/src/linux/mtab.ts +7 -7
  112. package/src/linux/volume_metadata.cpp +6 -1
  113. package/src/object.ts +1 -1
  114. package/src/options.ts +3 -3
  115. package/src/path.ts +2 -2
  116. package/src/remote_info.ts +5 -5
  117. package/src/system_volume.ts +8 -8
  118. package/src/test-utils/assert.ts +2 -2
  119. package/src/test-utils/debuglog-child.ts +1 -3
  120. package/src/test-utils/debuglog-enabled-child.ts +10 -0
  121. package/src/test-utils/hidden-tests.ts +1 -1
  122. package/src/test-utils/platform.ts +3 -3
  123. package/src/types/native_bindings.ts +3 -3
  124. package/src/types/volume_metadata.ts +2 -2
  125. package/src/unc.ts +2 -2
  126. package/src/uuid.ts +1 -1
  127. package/src/volume_health_status.ts +6 -6
  128. package/src/volume_metadata.ts +20 -23
  129. package/src/volume_mount_points.ts +12 -17
  130. package/src/windows/drive_status.h +30 -13
  131. package/src/windows/hidden.cpp +12 -0
  132. package/src/windows/volume_metadata.cpp +17 -7
  133. package/tsup.config.ts +8 -2
  134. package/dist/index.cjs +0 -1439
  135. package/dist/index.cjs.map +0 -1
  136. package/dist/index.mjs +0 -1396
  137. package/dist/index.mjs.map +0 -1
  138. package/dist/types/array.d.ts +0 -25
  139. package/dist/types/async.d.ts +0 -42
  140. package/dist/types/debuglog.d.ts +0 -3
  141. package/dist/types/defer.d.ts +0 -10
  142. package/dist/types/dirname.d.ts +0 -1
  143. package/dist/types/error.d.ts +0 -17
  144. package/dist/types/fs.d.ts +0 -22
  145. package/dist/types/glob.d.ts +0 -17
  146. package/dist/types/hidden.d.ts +0 -29
  147. package/dist/types/index.d.ts +0 -91
  148. package/dist/types/linux/dev_disk.d.ts +0 -13
  149. package/dist/types/linux/mount_points.d.ts +0 -6
  150. package/dist/types/linux/mtab.d.ts +0 -47
  151. package/dist/types/mount_point.d.ts +0 -2
  152. package/dist/types/number.d.ts +0 -3
  153. package/dist/types/object.d.ts +0 -18
  154. package/dist/types/options.d.ts +0 -33
  155. package/dist/types/path.d.ts +0 -17
  156. package/dist/types/platform.d.ts +0 -4
  157. package/dist/types/random.d.ts +0 -12
  158. package/dist/types/remote_info.d.ts +0 -6
  159. package/dist/types/stack_path.d.ts +0 -2
  160. package/dist/types/string.d.ts +0 -37
  161. package/dist/types/string_enum.d.ts +0 -19
  162. package/dist/types/system_volume.d.ts +0 -14
  163. package/dist/types/types/hidden_metadata.d.ts +0 -32
  164. package/dist/types/types/mount_point.d.ts +0 -46
  165. package/dist/types/types/native_bindings.d.ts +0 -51
  166. package/dist/types/types/options.d.ts +0 -47
  167. package/dist/types/types/remote_info.d.ts +0 -33
  168. package/dist/types/types/volume_metadata.d.ts +0 -46
  169. package/dist/types/unc.d.ts +0 -11
  170. package/dist/types/units.d.ts +0 -38
  171. package/dist/types/uuid.d.ts +0 -16
  172. package/dist/types/volume_health_status.d.ts +0 -24
  173. package/dist/types/volume_metadata.d.ts +0 -8
  174. package/dist/types/volume_mount_points.d.ts +0 -6
  175. package/jest.config.base.cjs +0 -63
  176. package/prebuilds/darwin-arm64/@photostructure+fs-metadata.glibc.node +0 -0
  177. package/prebuilds/linux-arm64/@photostructure+fs-metadata.musl.node +0 -0
  178. package/prebuilds/linux-x64/@photostructure+fs-metadata.musl.node +0 -0
  179. package/prebuilds/win32-x64/@photostructure+fs-metadata.glibc.node +0 -0
package/src/index.ts CHANGED
@@ -1,17 +1,17 @@
1
1
  // src/index.ts
2
2
 
3
3
  import NodeGypBuild from "node-gyp-build";
4
- import { debug, debugLogContext, isDebugEnabled } from "./debuglog.js";
5
- import { defer } from "./defer.js";
6
- import { _dirname } from "./dirname.js";
7
- import { findAncestorDir } from "./fs.js";
8
- import type { HideMethod, SetHiddenResult } from "./hidden.js";
4
+ import { debug, debugLogContext, isDebugEnabled } from "./debuglog";
5
+ import { defer } from "./defer";
6
+ import { _dirname } from "./dirname";
7
+ import { findAncestorDir } from "./fs";
8
+ import type { HideMethod, SetHiddenResult } from "./hidden";
9
9
  import {
10
10
  getHiddenMetadataImpl,
11
11
  isHiddenImpl,
12
12
  isHiddenRecursiveImpl,
13
13
  setHiddenImpl,
14
- } from "./hidden.js";
14
+ } from "./hidden";
15
15
  import {
16
16
  IncludeSystemVolumesDefault,
17
17
  LinuxMountTablePathsDefault,
@@ -20,26 +20,22 @@ import {
20
20
  SystemFsTypesDefault,
21
21
  SystemPathPatternsDefault,
22
22
  TimeoutMsDefault,
23
- } from "./options.js";
24
- import type {
25
- StringEnum,
26
- StringEnumKeys,
27
- StringEnumType,
28
- } from "./string_enum.js";
29
- import type { SystemVolumeConfig } from "./system_volume.js";
30
- import type { HiddenMetadata } from "./types/hidden_metadata.js";
31
- import type { MountPoint } from "./types/mount_point.js";
32
- import { NativeBindings } from "./types/native_bindings.js";
33
- import type { Options } from "./types/options.js";
34
- import type { VolumeMetadata } from "./types/volume_metadata.js";
35
- import type { VolumeHealthStatus } from "./volume_health_status.js";
36
- import { VolumeHealthStatuses } from "./volume_health_status.js";
23
+ } from "./options";
24
+ import type { StringEnum, StringEnumKeys, StringEnumType } from "./string_enum";
25
+ import type { SystemVolumeConfig } from "./system_volume";
26
+ import type { HiddenMetadata } from "./types/hidden_metadata";
27
+ import type { MountPoint } from "./types/mount_point";
28
+ import { NativeBindings } from "./types/native_bindings";
29
+ import type { Options } from "./types/options";
30
+ import type { VolumeMetadata } from "./types/volume_metadata";
31
+ import type { VolumeHealthStatus } from "./volume_health_status";
32
+ import { VolumeHealthStatuses } from "./volume_health_status";
37
33
  import {
38
34
  getAllVolumeMetadataImpl,
39
35
  getVolumeMetadataImpl,
40
- } from "./volume_metadata.js";
41
- import type { GetVolumeMountPointOptions } from "./volume_mount_points.js";
42
- import { getVolumeMountPointsImpl } from "./volume_mount_points.js";
36
+ } from "./volume_metadata";
37
+ import type { GetVolumeMountPointOptions } from "./volume_mount_points";
38
+ import { getVolumeMountPointsImpl } from "./volume_mount_points";
43
39
 
44
40
  export type {
45
41
  GetVolumeMountPointOptions,
@@ -11,7 +11,7 @@ std::mutex BlkidCache::mutex_;
11
11
 
12
12
  // Constructor: Initializes the blkid cache with proper error handling
13
13
  BlkidCache::BlkidCache() : cache_(nullptr) {
14
- std::lock_guard<std::mutex> lock(mutex_);
14
+ const std::lock_guard<std::mutex> lock(mutex_);
15
15
  DEBUG_LOG("[BlkidCache] initializing cache");
16
16
  if (blkid_get_cache(&cache_, nullptr) != 0) {
17
17
  DEBUG_LOG("[BlkidCache] failed to initialize cache");
@@ -23,17 +23,20 @@ BlkidCache::BlkidCache() : cache_(nullptr) {
23
23
  // Destructor: Safely releases the blkid cache resource
24
24
  BlkidCache::~BlkidCache() {
25
25
  if (cache_) {
26
- std::lock_guard<std::mutex> lock(mutex_);
27
- DEBUG_LOG("[BlkidCache] releasing cache");
28
- try {
29
- blkid_put_cache(cache_);
30
- cache_ = nullptr; // Avoid double-release
31
- DEBUG_LOG("[BlkidCache] cache released successfully");
32
- } catch (const std::exception &e) {
33
- DEBUG_LOG("[BlkidCache] error releasing cache: %s", e.what());
34
- // Optional: Log error during cache cleanup
35
- // std::cerr << "Error while releasing blkid cache: " << e.what()
36
- // << std::endl;
26
+ const std::lock_guard<std::mutex> lock(mutex_);
27
+ if (cache_) { // Double-check after acquiring lock
28
+ DEBUG_LOG("[BlkidCache] releasing cache");
29
+ try {
30
+ blkid_put_cache(cache_);
31
+ cache_ = nullptr; // Avoid double-release
32
+ DEBUG_LOG("[BlkidCache] cache released successfully");
33
+ } catch (const std::exception &e) {
34
+ DEBUG_LOG("[BlkidCache] error releasing cache: %s", e.what());
35
+ cache_ = nullptr; // Ensure it's nulled even on error
36
+ // Optional: Log error during cache cleanup
37
+ // std::cerr << "Error while releasing blkid cache: " << e.what()
38
+ // << std::endl;
39
+ }
37
40
  }
38
41
  }
39
42
  }
@@ -3,8 +3,8 @@
3
3
  import { Dirent } from "node:fs";
4
4
  import { readdir, readlink } from "node:fs/promises";
5
5
  import { join, resolve } from "node:path";
6
- import { debug } from "../debuglog.js";
7
- import { decodeEscapeSequences } from "../string.js";
6
+ import { debug } from "../debuglog";
7
+ import { decodeEscapeSequences } from "../string";
8
8
 
9
9
  /**
10
10
  * Gets the UUID from symlinks for a given device path asynchronously
@@ -21,16 +21,16 @@ void GioMountPointsWorker::Execute() {
21
21
  try {
22
22
  DEBUG_LOG("[GioMountPoints] processing mounts");
23
23
 
24
- MountIterator::forEachMount([this](GMount *mount, GFile *root) {
25
- GCharPtr path(g_file_get_path(root));
24
+ MountIterator::forEachMount([this](GMount * /*mount*/, GFile *root) {
25
+ const GCharPtr path(g_file_get_path(root));
26
26
  if (path) {
27
- GFileInfoPtr info(g_file_query_filesystem_info(
27
+ const GFileInfoPtr info(g_file_query_filesystem_info(
28
28
  root, G_FILE_ATTRIBUTE_FILESYSTEM_TYPE, nullptr, nullptr));
29
29
  if (info) {
30
30
  const char *fs_type_str = g_file_info_get_attribute_string(
31
31
  info.get(), G_FILE_ATTRIBUTE_FILESYSTEM_TYPE);
32
32
  if (fs_type_str) {
33
- GCharPtr fs_type(g_strdup(fs_type_str));
33
+ const GCharPtr fs_type(g_strdup(fs_type_str));
34
34
  DEBUG_LOG("[GioMountPoints] found {mountPoint: %s, fsType: %s}",
35
35
  path.get(), fs_type.get());
36
36
  MountPoint point{};
@@ -51,11 +51,11 @@ void GioMountPointsWorker::Execute() {
51
51
  }
52
52
 
53
53
  void GioMountPointsWorker::OnOK() {
54
- Napi::HandleScope scope(Env());
55
- Napi::Array result = Napi::Array::New(Env());
54
+ const Napi::HandleScope scope(Env());
55
+ const Napi::Array result = Napi::Array::New(Env());
56
56
 
57
57
  for (size_t i = 0; i < mountPoints.size(); i++) {
58
- Napi::Object point = Napi::Object::New(Env());
58
+ const Napi::Object point = Napi::Object::New(Env());
59
59
  point.Set("mountPoint", mountPoints[i].mountPoint);
60
60
  point.Set("fstype", mountPoints[i].fstype);
61
61
  result.Set(i, point);
@@ -41,17 +41,28 @@ void MountIterator::forEachMount(const MountCallback &callback) {
41
41
  // Take an extra reference on the mount while we work with it
42
42
  g_object_ref(mount);
43
43
 
44
- GioResource<GFile> root(g_mount_get_root(mount));
45
- if (G_IS_FILE(root.get())) {
46
- bool continue_iteration = callback(mount, root.get());
47
- g_object_unref(mount);
44
+ try {
45
+ const GioResource<GFile> root(g_mount_get_root(mount));
46
+
47
+ // Check both for null and valid GFile
48
+ if (root.get() && G_IS_FILE(root.get())) {
49
+ const bool continue_iteration = callback(mount, root.get());
50
+ g_object_unref(mount);
48
51
 
49
- if (!continue_iteration) {
50
- break;
52
+ if (!continue_iteration) {
53
+ break;
54
+ }
55
+ } else {
56
+ DEBUG_LOG(
57
+ "[gio::MountIterator::forEachMount] Invalid root file object");
58
+ g_object_unref(mount);
51
59
  }
52
- } else {
53
- DEBUG_LOG("[gio::MountIterator::forEachMount] Invalid root file object");
60
+ } catch (const std::exception &e) {
61
+ DEBUG_LOG("[gio::MountIterator::forEachMount] Exception during mount "
62
+ "processing: %s",
63
+ e.what());
54
64
  g_object_unref(mount);
65
+ throw; // Re-throw to maintain current behavior
55
66
  }
56
67
  }
57
68
 
@@ -17,7 +17,7 @@ void addMountMetadata(const std::string &mountPoint, VolumeMetadata &metadata) {
17
17
  mountPoint.c_str());
18
18
 
19
19
  MountIterator::forEachMount([&](GMount *mount, GFile *root) {
20
- GCharPtr path(g_file_get_path(root));
20
+ const GCharPtr path(g_file_get_path(root));
21
21
  if (!path || mountPoint != path.get()) {
22
22
  return true; // Continue iteration
23
23
  }
@@ -27,25 +27,25 @@ void addMountMetadata(const std::string &mountPoint, VolumeMetadata &metadata) {
27
27
  path.get());
28
28
 
29
29
  // Get volume information
30
- GObjectPtr<GVolume> volume(g_mount_get_volume(mount));
31
- if (volume) {
32
- GCharPtr label(g_volume_get_name(volume.get()));
33
- if (label) {
34
- DEBUG_LOG("[gio::addMountMetadata] {mountPoint: %s, label: %s",
30
+ const GObjectPtr<GVolume> volume(g_mount_get_volume(mount));
31
+ if (volume && volume.get()) {
32
+ const GCharPtr label(g_volume_get_name(volume.get()));
33
+ if (label && label.get()) {
34
+ DEBUG_LOG("[gio::addMountMetadata] {mountPoint: %s, label: %s}",
35
35
  path.get(), label.get());
36
36
  metadata.label = label.get();
37
37
  }
38
38
  }
39
39
 
40
- GCharPtr mount_name(g_mount_get_name(mount));
40
+ const GCharPtr mount_name(g_mount_get_name(mount));
41
41
  if (mount_name) {
42
42
  metadata.mountName = mount_name.get();
43
43
  }
44
44
 
45
- GObjectPtr<GFile> location(g_mount_get_default_location(mount));
46
- if (location) {
47
- GCharPtr uri(g_file_get_uri(location.get()));
48
- if (uri) {
45
+ const GObjectPtr<GFile> location(g_mount_get_default_location(mount));
46
+ if (location && location.get()) {
47
+ const GCharPtr uri(g_file_get_uri(location.get()));
48
+ if (uri && uri.get()) {
49
49
  DEBUG_LOG("[gio::addMountMetadata] {mountPoint: %s, uri: %s}",
50
50
  path.get(), uri.get());
51
51
  metadata.uri = uri.get();
@@ -53,13 +53,13 @@ void addMountMetadata(const std::string &mountPoint, VolumeMetadata &metadata) {
53
53
  }
54
54
 
55
55
  if (metadata.fstype.empty()) {
56
- GFileInfoPtr info(g_file_query_filesystem_info(
56
+ const GFileInfoPtr info(g_file_query_filesystem_info(
57
57
  root, G_FILE_ATTRIBUTE_FILESYSTEM_TYPE, nullptr, nullptr));
58
58
  if (info) {
59
59
  const char *fs_type_str = g_file_info_get_attribute_string(
60
60
  info.get(), G_FILE_ATTRIBUTE_FILESYSTEM_TYPE);
61
61
  if (fs_type_str) {
62
- GCharPtr fs_type(g_strdup(fs_type_str));
62
+ const GCharPtr fs_type(g_strdup(fs_type_str));
63
63
  DEBUG_LOG("[gio::addMountMetadata] {mountPoint: %s, fsType: %s}",
64
64
  path.get(), fs_type.get());
65
65
  metadata.fstype = fs_type.get();
@@ -68,9 +68,9 @@ void addMountMetadata(const std::string &mountPoint, VolumeMetadata &metadata) {
68
68
  }
69
69
 
70
70
  if (metadata.mountFrom.empty()) {
71
- GObjectPtr<GDrive> drive(g_mount_get_drive(mount));
71
+ const GObjectPtr<GDrive> drive(g_mount_get_drive(mount));
72
72
  if (drive) {
73
- GCharPtr unix_device(g_drive_get_identifier(
73
+ const GCharPtr unix_device(g_drive_get_identifier(
74
74
  drive.get(), G_DRIVE_IDENTIFIER_KIND_UNIX_DEVICE));
75
75
  if (unix_device) {
76
76
  DEBUG_LOG("[gio::addMountMetadata] {mountPoint: %s, mountFrom: %s}",
@@ -1,14 +1,14 @@
1
1
  // src/linux/mount_points.ts
2
2
  import { readFile } from "node:fs/promises";
3
- import { debug } from "../debuglog.js";
4
- import { toError, WrappedError } from "../error.js";
5
- import { isMountPoint } from "../mount_point.js";
6
- import { compactValues } from "../object.js";
7
- import { optionsWithDefaults } from "../options.js";
8
- import { type MountPoint } from "../types/mount_point.js";
9
- import type { NativeBindingsFn } from "../types/native_bindings.js";
10
- import type { Options } from "../types/options.js";
11
- import { MountEntry, mountEntryToMountPoint, parseMtab } from "./mtab.js";
3
+ import { debug } from "../debuglog";
4
+ import { toError, WrappedError } from "../error";
5
+ import { isMountPoint } from "../mount_point";
6
+ import { compactValues } from "../object";
7
+ import { optionsWithDefaults } from "../options";
8
+ import { type MountPoint } from "../types/mount_point";
9
+ import type { NativeBindingsFn } from "../types/native_bindings";
10
+ import type { Options } from "../types/options";
11
+ import { MountEntry, mountEntryToMountPoint, parseMtab } from "./mtab";
12
12
 
13
13
  export async function getLinuxMountPoints(
14
14
  native: NativeBindingsFn,
package/src/linux/mtab.ts CHANGED
@@ -1,17 +1,17 @@
1
1
  // src/linux/mtab.ts
2
2
 
3
- import { toInt } from "../number.js";
4
- import { normalizePosixPath } from "../path.js";
5
- import { extractRemoteInfo } from "../remote_info.js";
3
+ import { toInt } from "../number";
4
+ import { normalizePosixPath } from "../path";
5
+ import { extractRemoteInfo } from "../remote_info";
6
6
  import {
7
7
  decodeEscapeSequences,
8
8
  encodeEscapeSequences,
9
9
  isBlank,
10
10
  toNotBlank,
11
- } from "../string.js";
12
- import { isSystemVolume, SystemVolumeConfig } from "../system_volume.js";
13
- import type { MountPoint } from "../types/mount_point.js";
14
- import type { VolumeMetadata } from "../types/volume_metadata.js";
11
+ } from "../string";
12
+ import { isSystemVolume, SystemVolumeConfig } from "../system_volume";
13
+ import type { MountPoint } from "../types/mount_point";
14
+ import type { VolumeMetadata } from "../types/volume_metadata";
15
15
 
16
16
  /**
17
17
  * Represents an entry in the mount table.
@@ -18,7 +18,12 @@ public:
18
18
  LinuxMetadataWorker(const std::string &mountPoint,
19
19
  const VolumeMetadataOptions &options,
20
20
  const Napi::Promise::Deferred &deferred)
21
- : MetadataWorkerBase(mountPoint, deferred), options_(options) {}
21
+ : MetadataWorkerBase(mountPoint, deferred), options_(options) {
22
+ // Validate mount point is not empty
23
+ if (mountPoint.empty()) {
24
+ throw std::invalid_argument("Mount point cannot be empty");
25
+ }
26
+ }
22
27
 
23
28
  void Execute() override {
24
29
  try {
package/src/object.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/object.js
2
2
 
3
- import { isNotBlank, isString } from "./string.js";
3
+ import { isNotBlank, isString } from "./string";
4
4
 
5
5
  /**
6
6
  * @return true iff value is an object and not an array
package/src/options.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  // src/options.ts
2
2
 
3
3
  import { availableParallelism } from "node:os";
4
- import { compactValues, isObject } from "./object.js";
5
- import { isWindows } from "./platform.js";
6
- import type { Options } from "./types/options.js";
4
+ import { compactValues, isObject } from "./object";
5
+ import { isWindows } from "./platform";
6
+ import type { Options } from "./types/options";
7
7
 
8
8
  /**
9
9
  * Default timeout in milliseconds for {@link Options.timeoutMs}.
package/src/path.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  // src/path.ts
2
2
 
3
3
  import { dirname, resolve } from "node:path";
4
- import { isWindows } from "./platform.js";
5
- import { isBlank } from "./string.js";
4
+ import { isWindows } from "./platform";
5
+ import { isBlank } from "./string";
6
6
 
7
7
  export function normalizePath(
8
8
  mountPoint: string | undefined,
@@ -1,10 +1,10 @@
1
1
  // src/remote_info.ts
2
2
 
3
- import { debug } from "./debuglog.js";
4
- import { compactValues, isObject } from "./object.js";
5
- import { isWindows } from "./platform.js";
6
- import { isBlank, isNotBlank, toS } from "./string.js";
7
- import { RemoteInfo } from "./types/remote_info.js";
3
+ import { debug } from "./debuglog";
4
+ import { compactValues, isObject } from "./object";
5
+ import { isWindows } from "./platform";
6
+ import { isBlank, isNotBlank, toS } from "./string";
7
+ import { RemoteInfo } from "./types/remote_info";
8
8
 
9
9
  export function isRemoteInfo(obj: unknown): obj is RemoteInfo {
10
10
  if (!isObject(obj)) return false;
@@ -1,13 +1,13 @@
1
1
  // src/system_volume.ts
2
2
 
3
- import { debug } from "./debuglog.js";
4
- import { compileGlob } from "./glob.js";
5
- import { SystemFsTypesDefault, SystemPathPatternsDefault } from "./options.js";
6
- import { normalizePath } from "./path.js";
7
- import { isWindows } from "./platform.js";
8
- import { isNotBlank } from "./string.js";
9
- import type { MountPoint } from "./types/mount_point.js";
10
- import type { Options } from "./types/options.js";
3
+ import { debug } from "./debuglog";
4
+ import { compileGlob } from "./glob";
5
+ import { SystemFsTypesDefault, SystemPathPatternsDefault } from "./options";
6
+ import { normalizePath } from "./path";
7
+ import { isWindows } from "./platform";
8
+ import { isNotBlank } from "./string";
9
+ import type { MountPoint } from "./types/mount_point";
10
+ import type { Options } from "./types/options";
11
11
 
12
12
  /**
13
13
  * Configuration for system volume detection
@@ -1,7 +1,7 @@
1
1
  /* eslint-disable @typescript-eslint/no-non-null-assertion */
2
2
  // src/test-utils/assert.ts
3
- import { isMacOS } from "../platform.js";
4
- import type { VolumeMetadata } from "../types/volume_metadata.js";
3
+ import { isMacOS } from "../platform";
4
+ import type { VolumeMetadata } from "../types/volume_metadata";
5
5
 
6
6
  /**
7
7
  * Asserts that the given metadata object has valid filesystem metadata
@@ -1,6 +1,4 @@
1
- #!/usr/bin/env -S npx tsx
2
-
3
- import { debugLogContext, isDebugEnabled } from "../debuglog.js";
1
+ import { debugLogContext, isDebugEnabled } from "../debuglog";
4
2
 
5
3
  try {
6
4
  const result = {
@@ -0,0 +1,10 @@
1
+ import { debug } from "../debuglog";
2
+
3
+ // This will be run with NODE_DEBUG set, so debug should be enabled
4
+ debug("test message %s %d", "hello", 42);
5
+ debug("simple message");
6
+ debug("object %o", { key: "value" });
7
+
8
+ // Signal successful completion
9
+ console.log("DONE");
10
+ process.exit(0);
@@ -1,6 +1,6 @@
1
1
  import { mkdir, writeFile } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
- import { isHidden, isHiddenRecursive, setHidden } from "../..";
3
+ import { isHidden, isHiddenRecursive, setHidden } from "../index";
4
4
 
5
5
  /**
6
6
  * This function exercises the hidden file functionality and is used by both
@@ -4,9 +4,9 @@ import { mkdirSync } from "node:fs";
4
4
  import { homedir } from "node:os";
5
5
  import { join } from "node:path";
6
6
  import { env, platform } from "node:process";
7
- import { normalizePath } from "../path.js";
8
- import { isMacOS, isWindows } from "../platform.js";
9
- import { toNotBlank } from "../string.js";
7
+ import { normalizePath } from "../path";
8
+ import { isMacOS, isWindows } from "../platform";
9
+ import { toNotBlank } from "../string";
10
10
 
11
11
  /**
12
12
  * Helper function to skip tests based on platform
@@ -1,8 +1,8 @@
1
1
  // src/types/native_bindings.ts
2
2
 
3
- import type { MountPoint } from "./mount_point.js";
4
- import type { Options } from "./options.js";
5
- import type { VolumeMetadata } from "./volume_metadata.js";
3
+ import type { MountPoint } from "./mount_point";
4
+ import type { Options } from "./options";
5
+ import type { VolumeMetadata } from "./volume_metadata";
6
6
 
7
7
  export interface NativeBindings {
8
8
  /**
@@ -1,7 +1,7 @@
1
1
  // src/types/volume_metadata.ts
2
2
 
3
- import type { MountPoint } from "./mount_point.js";
4
- import type { RemoteInfo } from "./remote_info.js";
3
+ import type { MountPoint } from "./mount_point";
4
+ import type { RemoteInfo } from "./remote_info";
5
5
 
6
6
  /**
7
7
  * Metadata associated to a volume.
package/src/unc.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  // src/unc.ts
2
2
 
3
- import { isBlank, isString } from "./string.js";
4
- import { RemoteInfo } from "./types/remote_info.js";
3
+ import { isBlank, isString } from "./string";
4
+ import { RemoteInfo } from "./types/remote_info";
5
5
 
6
6
  /**
7
7
  * Checks if a string is formatted as a valid UNC path.
package/src/uuid.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/uuid.ts
2
2
 
3
- import { toS } from "./string.js";
3
+ import { toS } from "./string";
4
4
 
5
5
  const uuidRegex = /[a-z0-9][a-z0-9-]{7,}/i;
6
6
 
@@ -1,11 +1,11 @@
1
1
  // src/volume_health_status.ts
2
2
 
3
- import { TimeoutError } from "./async.js";
4
- import { debug } from "./debuglog.js";
5
- import { toError } from "./error.js";
6
- import { canReaddir } from "./fs.js";
7
- import { isObject } from "./object.js";
8
- import { stringEnum, StringEnumKeys } from "./string_enum.js";
3
+ import { TimeoutError } from "./async";
4
+ import { debug } from "./debuglog";
5
+ import { toError } from "./error";
6
+ import { canReaddir } from "./fs";
7
+ import { isObject } from "./object";
8
+ import { stringEnum, StringEnumKeys } from "./string_enum";
9
9
 
10
10
  /**
11
11
  * Health statuses for volumes (mostly applicable to Windows).
@@ -1,34 +1,31 @@
1
1
  // src/volume_metadata.ts
2
2
 
3
- import { mapConcurrent, withTimeout } from "./async.js";
4
- import { debug } from "./debuglog.js";
5
- import { WrappedError } from "./error.js";
6
- import { getLabelFromDevDisk, getUuidFromDevDisk } from "./linux/dev_disk.js";
7
- import { getLinuxMtabMetadata } from "./linux/mount_points.js";
3
+ import { mapConcurrent, withTimeout } from "./async";
4
+ import { debug } from "./debuglog";
5
+ import { WrappedError } from "./error";
6
+ import { getLabelFromDevDisk, getUuidFromDevDisk } from "./linux/dev_disk";
7
+ import { getLinuxMtabMetadata } from "./linux/mount_points";
8
8
  import {
9
9
  type MtabVolumeMetadata,
10
10
  mountEntryToPartialVolumeMetadata,
11
- } from "./linux/mtab.js";
12
- import { compactValues } from "./object.js";
13
- import { IncludeSystemVolumesDefault, optionsWithDefaults } from "./options.js";
14
- import { normalizePath } from "./path.js";
15
- import { isLinux, isWindows } from "./platform.js";
16
- import { extractRemoteInfo, isRemoteFsType } from "./remote_info.js";
17
- import { isBlank, isNotBlank } from "./string.js";
18
- import { assignSystemVolume } from "./system_volume.js";
11
+ } from "./linux/mtab";
12
+ import { compactValues } from "./object";
13
+ import { IncludeSystemVolumesDefault, optionsWithDefaults } from "./options";
14
+ import { normalizePath } from "./path";
15
+ import { isLinux, isWindows } from "./platform";
16
+ import { extractRemoteInfo, isRemoteFsType } from "./remote_info";
17
+ import { isBlank, isNotBlank } from "./string";
18
+ import { assignSystemVolume } from "./system_volume";
19
19
  import type {
20
20
  GetVolumeMetadataOptions,
21
21
  NativeBindingsFn,
22
- } from "./types/native_bindings.js";
23
- import type { Options } from "./types/options.js";
24
- import type { VolumeMetadata } from "./types/volume_metadata.js";
25
- import { parseUNCPath } from "./unc.js";
26
- import { extractUUID } from "./uuid.js";
27
- import {
28
- VolumeHealthStatuses,
29
- directoryStatus,
30
- } from "./volume_health_status.js";
31
- import { getVolumeMountPointsImpl } from "./volume_mount_points.js";
22
+ } from "./types/native_bindings";
23
+ import type { Options } from "./types/options";
24
+ import type { VolumeMetadata } from "./types/volume_metadata";
25
+ import { parseUNCPath } from "./unc";
26
+ import { extractUUID } from "./uuid";
27
+ import { VolumeHealthStatuses, directoryStatus } from "./volume_health_status";
28
+ import { getVolumeMountPointsImpl } from "./volume_mount_points";
32
29
 
33
30
  export async function getVolumeMetadataImpl(
34
31
  o: GetVolumeMetadataOptions & Options,
@@ -1,22 +1,17 @@
1
1
  // src/mount_point.ts
2
2
 
3
- import { uniqBy } from "./array.js";
4
- import { mapConcurrent, withTimeout } from "./async.js";
5
- import { debug } from "./debuglog.js";
6
- import { getLinuxMountPoints } from "./linux/mount_points.js";
7
- import { compactValues } from "./object.js";
8
- import { isMacOS, isWindows } from "./platform.js";
9
- import {
10
- isBlank,
11
- isNotBlank,
12
- sortObjectsByLocale,
13
- toNotBlank,
14
- } from "./string.js";
15
- import { assignSystemVolume, SystemVolumeConfig } from "./system_volume.js";
16
- import type { MountPoint } from "./types/mount_point.js";
17
- import type { NativeBindingsFn } from "./types/native_bindings.js";
18
- import type { Options } from "./types/options.js";
19
- import { directoryStatus } from "./volume_health_status.js";
3
+ import { uniqBy } from "./array";
4
+ import { mapConcurrent, withTimeout } from "./async";
5
+ import { debug } from "./debuglog";
6
+ import { getLinuxMountPoints } from "./linux/mount_points";
7
+ import { compactValues } from "./object";
8
+ import { isMacOS, isWindows } from "./platform";
9
+ import { isBlank, isNotBlank, sortObjectsByLocale, toNotBlank } from "./string";
10
+ import { assignSystemVolume, SystemVolumeConfig } from "./system_volume";
11
+ import type { MountPoint } from "./types/mount_point";
12
+ import type { NativeBindingsFn } from "./types/native_bindings";
13
+ import type { Options } from "./types/options";
14
+ import { directoryStatus } from "./volume_health_status";
20
15
 
21
16
  export type GetVolumeMountPointOptions = Partial<
22
17
  Pick<