count.macro Babel宏计算文件行数与单词数

想知道文件中到底有多少行代码或者多少个单词?count.macro来帮你!它是一个 Babel 宏,能在构建时就计算出源文件的行数和单词数,超方便。你只需要安装npm install --save-dev count.macro,在代码里这样写:

import { lines, linesIn, wordsIn } from 'count.macro';
console.log(`This file has ${lines} lines`);
。代码会自动转译,输出就像这样:
console.log(`This file has 7 lines`);
。对于像 CRA、Gatsby、Next 这些项目都挺兼容的,能省去你手动统计的烦恼。
使用时,记得linesInwordsIn支持传入路径,能读取其他文件的行数和单词数哦。挺,效果也直观。

zip
count_macro-master.zip 预估大小:17个文件
folder
count.macro-master 文件夹
folder
example 文件夹
file
lines.txt 12B
file
index.ts 273B
file
words.txt 28B
file
package.json 1KB
folder
.github 文件夹
file
dependabot.yml 125B
folder
workflows 文件夹
file
main.yml 251B
file
.prettierrc 79B
folder
tests 文件夹
file
index.test.ts 641B
file
lines.txt 12B
folder
__snapshots__ 文件夹
file
index.test.ts.snap 836B
file
words.txt 14B
file
LICENSE 1KB
folder
src 文件夹
file
index.macro.ts 3KB
file
tsconfig.json 468B
file
.gitignore 258B
file
README.md 2KB
file
yarn.lock 177KB
zip 文件大小:77.7KB