-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstat.cjs
More file actions
22 lines (19 loc) · 729 Bytes
/
stat.cjs
File metadata and controls
22 lines (19 loc) · 729 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
const { promises: fsPromises } = require('fs'),
{ join } = require('path'),
{ version } = require('./package.json');
const DIST_DIR = join(__dirname, 'dist');
console.log(`# dist info (v${version})\n`);
fsPromises.readdir(DIST_DIR)
.then(files => files.reduce(
(prevPromise, fileName) => prevPromise.then(async () => {
const file = join(DIST_DIR, fileName),
size = (await fsPromises.stat(file)).size / 1024,
info = [
(fileName + ' ').padEnd(30, '.'),
size.toFixed(3).toString().padStart(7),
'KB'
].join(' ');
console.log(info);
}),
Promise.resolve()
));