项目作者: simoneb

项目描述 :
Node CLI or module to calculate folder size
高级语言: JavaScript
项目地址: git://github.com/simoneb/fast-folder-size.git
创建时间: 2021-03-09T14:49:28Z
项目社区:https://github.com/simoneb/fast-folder-size

开源协议:

下载


The license of this software has changed to AWISC - Anti War ISC License

fast-folder-size

ci

Node CLI or module to calculate folder size.

It uses:

  • Sysinternals DU on Windows, automatically downloaded at
    installation time because the license does not allow redistribution. See below about specifying the download location.
  • native du on other platforms

Installation

  1. npm i fast-folder-size

Usage

Programmatically

  1. const { promisify } = require('util')
  2. const fastFolderSize = require('fast-folder-size')
  3. const fastFolderSizeSync = require('fast-folder-size/sync')
  4. // callback
  5. fastFolderSize('.', (err, bytes) => {
  6. if (err) {
  7. throw err
  8. }
  9. console.log(bytes)
  10. })
  11. // promise
  12. const fastFolderSizeAsync = promisify(fastFolderSize)
  13. const bytes = await fastFolderSizeAsync('.')
  14. console.log(bytes)
  15. // sync
  16. const bytes = fastFolderSizeSync('.')
  17. console.log(bytes)

Aborting

The non-sync version of the API also supports AbortSignal, to abort the operation while in progress.

  1. const fastFolderSize = require('fast-folder-size')
  2. const controller = new AbortController()
  3. fastFolderSize('.', { signal: controller.signal }, (err, bytes) => {
  4. if (err) {
  5. throw err
  6. }
  7. console.log(bytes)
  8. })
  9. controller.abort()

Command line

  1. fast-folder-size .

Downloading the Sysinternals DU.zip

By default the Sysinternals DU.zip is downloaded from https://download.sysinternals.com/files/DU.zip.

If you need to change this, e.g. to download from an internal package repository
or re-use an existing du.zip, you can set the FAST_FOLDER_SIZE_DU_ZIP_LOCATION environment variable.

For example:

  1. export FAST_FOLDER_SIZE_DU_ZIP_LOCATION="https://your.internal.repository/DU.zip"

or

  1. export FAST_FOLDER_SIZE_DU_ZIP_LOCATION="D://download/du.zip"