Skip to content

Releases

v2.1.0 - Add getDirectorySize

Choose a tag to compare

@SilverStudio1985 SilverStudio1985 released this 24 Jul 09:48

✨ Added

  • getDirectorySize(path): 递归遍历目录树,返回总大小、文件数、目录数
    • 同步 / 异步 / BigInt 全套变体(getDirectorySizeSync / getDirectorySizeSyncBig / getDirectorySize / getDirectorySizeBig)
    • 支持 Node callback 与 Promise 两种异步风格
    • Windows: FindFirstFileW / FindNextFileW
    • POSIX: opendir / readdir / lstat
    • 跳过符号链接 / junctions / reparse points(避免循环和重复计数)
    • 迭代遍历(非递归),避免深层目录栈溢出

🐛 Fixed

  • 修复 MultiByteToWideChar 写入 std::wstring 时尾部多一个 \0,导致后续路径拼接被截断的 bug

npm: https://www.npmjs.com/package/@iislove/diskusage
Install: npm install @iislove/diskusage

v2.0.0 - Initial N-API rewrite

Choose a tag to compare

@SilverStudio1985 SilverStudio1985 released this 27 Jun 00:12

Overview

@iislove/diskusage is an N-API rewrite of the classic jduncanator/node-diskusage. The original project has been unmaintained since 1.2.0 (2023-09); its NAN-based native binding is increasingly hard to build on modern Node, and there are no macOS arm64 prebuilds.

This release targets:

  • Node-API v8 + node-addon-api 6.x instead of NAN — ABI-stable across Node 14.21.3 / 18 / 20 / 22 / 24 / Electron 16+
  • Prebuilt binaries for 6 platforms (win32-x64/arm64, darwin-x64/arm64, linux-x64/arm64) — no electron-rebuild needed
  • Fully backward-compatible API + BigInt variants + volume enumeration + physical-disk view

✨ Added

  • BigInt precision API: checkSyncBig / checkBig / listVolumesBig / listPhysicalDisksBig etc.
  • Enumerate all volumes: listVolumes() / listVolumesSync()
    • Windows: GetLogicalDriveStringsW
    • macOS: getmntinfo(MNT_NOWAIT)
    • Linux: parses /proc/mounts, auto-filters pseudo filesystems
  • Physical-disk view: listPhysicalDisks() / listPhysicalDisksSync()
    • Deduplicates macOS APFS container volumes
    • Merges Linux partitions (/dev/sda1, /dev/sda2 → /dev/sda)
    • Each entry includes mountpoints: string[]
  • Richer volume metadata: name, fs, type (fixed/removable/network/cdrom/ramdisk), device, ok, error

🔄 Changed

  • NAN/C++ → node-addon-api / N-API v8
  • node-gyp → node-gyp-build + prebuildify (prebuilt-first, source-build fallback)
  • MSVC /utf-8 enabled
  • MACOSX_DEPLOYMENT_TARGET=10.15, C++17

✅ Compatibility

  • check / checkSync behaves identically to the original diskusage package
  • Same { available, free, total } output, same callback/Promise patterns
  • Drop-in replacement: just change the require string

📦 Platform matrix

Platform Arch Build
Windows x64 native (windows-2022)
Windows arm64 cross-compile (windows-2022)
macOS 14 x64 cross-compile via -arch x86_64
macOS 14 arm64 native (Apple Silicon)
Ubuntu 22.04 x64 native
Ubuntu 22.04 arm64 native (arm64 runner)

📁 Demos

  • demo/node/: 5 invocation styles + volume / physical-disk enumeration
  • demo/electron/:
    • Card-based disk list with progress bar
    • Number / BigInt toggle
    • All-volumes / physical-disks toggle
    • Binding-source badge (prebuild vs local-build)

🛠️ Tooling

  • node-addon-api ^6.1
  • node-gyp-build ^4.8
  • prebuildify ^6.0
  • GitHub Actions matrix CI + matrix prebuild + npm publish with provenance

🙏 Acknowledgments

Thanks to @jduncanator for the original node-diskusage. MIT licensed.


npm: https://www.npmjs.com/package/@iislove/diskusage
Install: npm install @iislove/diskusage