mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-01-18 20:09:27 +08:00
改进行数显示
This commit is contained in:
parent
c179f05602
commit
e9821ef1e5
@ -11,7 +11,8 @@
|
||||
"preview": "vite preview",
|
||||
"update": "ts-node-esm script/update.ts",
|
||||
"declare": "ts-node-esm script/declare.ts",
|
||||
"type": "vue-tsc --noEmit"
|
||||
"type": "vue-tsc --noEmit",
|
||||
"lines": "ts-node-esm script/lines.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ant-design/icons-vue": "^6.1.0",
|
||||
|
@ -1,9 +1,11 @@
|
||||
import fs from 'fs-extra';
|
||||
import { resolve } from 'path';
|
||||
import { extname, resolve } from 'path';
|
||||
|
||||
(async function () {
|
||||
const dir = './src';
|
||||
let total = 0;
|
||||
let totalLines = 0;
|
||||
let totalFiles = 0;
|
||||
const list: Record<string, [number, number]> = {};
|
||||
|
||||
const check = async (dir: string) => {
|
||||
const d = await fs.readdir(dir);
|
||||
@ -18,7 +20,12 @@ import { resolve } from 'path';
|
||||
) {
|
||||
const file = await fs.readFile(resolve(dir, one), 'utf-8');
|
||||
const lines = file.split('\n').length;
|
||||
total += lines;
|
||||
const ext = extname(one);
|
||||
list[ext] ??= [0, 0];
|
||||
list[ext][0]++;
|
||||
list[ext][1] += lines;
|
||||
totalLines += lines;
|
||||
totalFiles++;
|
||||
}
|
||||
} else {
|
||||
await check(resolve(dir, one));
|
||||
@ -27,5 +34,16 @@ import { resolve } from 'path';
|
||||
};
|
||||
await check(dir);
|
||||
|
||||
console.log(total);
|
||||
for (const [ext, [file, lines]] of Object.entries(list)) {
|
||||
console.log(
|
||||
`${ext.slice(1).padEnd(7, ' ')}files: ${file
|
||||
.toString()
|
||||
.padEnd(6, ' ')}lines: ${lines}`
|
||||
);
|
||||
}
|
||||
console.log(
|
||||
`\x1b[33mtotal files: ${totalFiles
|
||||
.toString()
|
||||
.padEnd(6, ' ')}lines: ${totalLines}\x1b[0m`
|
||||
);
|
||||
})();
|
||||
|
Loading…
Reference in New Issue
Block a user