mirror of
https://github.com/unanmed/HumanBreak.git
synced 2025-01-19 04:19:30 +08:00
32 lines
912 B
TypeScript
32 lines
912 B
TypeScript
import fs from 'fs-extra';
|
|
import { resolve } from 'path';
|
|
|
|
(async function () {
|
|
const dir = './src';
|
|
let total = 0;
|
|
|
|
const check = async (dir: string) => {
|
|
const d = await fs.readdir(dir);
|
|
for await (const one of d) {
|
|
const stat = await fs.stat(resolve(dir, one));
|
|
if (stat.isFile()) {
|
|
if (
|
|
['.ts', '.tsx', '.js', '.jsx', '.vue', '.less'].some(v =>
|
|
one.endsWith(v)
|
|
) &&
|
|
!one.endsWith('.d.ts')
|
|
) {
|
|
const file = await fs.readFile(resolve(dir, one), 'utf-8');
|
|
const lines = file.split('\n').length;
|
|
total += lines;
|
|
}
|
|
} else {
|
|
await check(resolve(dir, one));
|
|
}
|
|
}
|
|
};
|
|
await check(dir);
|
|
|
|
console.log(total);
|
|
})();
|