Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fast-folder-size

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fast-folder-size - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

31

index.js

@@ -7,4 +7,5 @@ 'use strict'

function fastFolderSize(target, cb) {
// windows
if (process.platform === 'win32') {
exec(
return exec(
`${path.join(

@@ -16,8 +17,5 @@ __dirname,

(err, stdout) => {
if (err) {
return cb(err)
}
if (err) return cb(err)
const match = /Size:\s+(.+) bytes/.exec(stdout)
const bytes = match[1].replace(/\./g, '')

@@ -28,15 +26,14 @@

)
} else {
exec(`du -s ${target}`, (err, stdout) => {
if (err) {
return cb(err)
}
}
const match = /^(\d+)/.exec(stdout)
// other platforms
exec(`du -s ${target}`, (err, stdout) => {
if (err) return cb(err)
const bytes = Number(match[1]) * 1024
const match = /^(\d+)/.exec(stdout)
cb(null, bytes)
})
}
const bytes = Number(match[1]) * 1024
cb(null, bytes)
})
}

@@ -47,3 +44,3 @@

if (require.main === module) {
fastFolderSize(process.argv.slice(2)[0], (err, result) => {
fastFolderSize(process.argv.slice(2)[0], (err, bytes) => {
if (err) {

@@ -53,4 +50,4 @@ throw err

console.log(result)
console.log(bytes)
})
}
{
"name": "fast-folder-size",
"version": "1.0.0",
"version": "1.0.1",
"description": "Node CLI or module to calculate folder size",
"main": "index.js",
"bin": "index.js",
"bin": {
"fast-folder-size": "index.js"
},
"author": "Simone Busoli <simone.busoli@gmail.com>",

@@ -16,2 +18,5 @@ "scripts": {

],
"repository": {
"url": "https://github.com/simoneb/fast-folder-size.git"
},
"license": "ISC",

@@ -18,0 +23,0 @@ "dependencies": {

# fast-folder-size
Node CLI or module to calculate folder size.
It uses:
- [Sysinternals DU](https://docs.microsoft.com/en-us/sysinternals/downloads/du) on Windows, automatically downloaded at installation time because the license does not allow redistribution
- native `du` on other platforms
## Installation
```
npm i fast-folder-size
```
## Usage
### Programmatically
```js
const { promisify } = require('util')
const fastFolderSize = require('fast-folder-size')
// callback
fastFolderSize('.', (err, bytes) => {
if (err) {
throw err
}
console.log(bytes)
})
// promise
const fastFolderSizeAsync = promisify(fastFolderSize)
const bytes = await fastFolderSizeAsync('.')
console.log(bytes)
```
### Command line
```bash
fast-folder-size .
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc