file-size-stats
v1.0.8
Published
This Node.js program calculates the total size of .webp and .json and .mp3 files within a specified directory. It outputs detailed information in a JSON file, including individual file sizes, formatted sizes, and the total size.
Downloads
2
Readme
Installation
Install dependencies:
npm i file-size-stats
Usage
Create a
json
folder in the root of your project where all the.json
files you have created will be storedAdd to script
getFileSizeStats
in thepackage.json
:
"scripts": {
"getFileSizeStats": "node $(find ./ -path '*/file-size-stats/src/index.js')"
},
- Run the script
npm run getFileSizeStats [folder-name]
Replace [folder-name]
with the directory you want to analyze.
Example
Running npm run getFileSizeStats [folder-name]
will generate a JSON file [folder-name]-stats.json
with content similar to:
{
"files": [
{
"filePath": "[folder-name]/file1.json",
"size": 1024,
"formattedSize": "1 KiB"
},
{
"filePath": "[folder-name]/file2.webp",
"size": 500,
"formattedSize": "500 Bytes"
},
{
"filePath": "[folder-name]/subfolder/file3.webp",
"size": 2048,
"formattedSize": "2 KiB"
}
],
"totalSize": "3.50 KiB",
"totalSizeInBytes": 3572
}
Author: vladyslavfolkuian