4 Star 90 Fork 39

JayFong/docker-YApi

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
clean.ts 1.26 KB
一键复制 编辑 原始数据 按行查看 历史
JayFong 提交于 2021-08-30 17:42 . fix: 清理优化
import fs from 'fs-extra'
import { join, parse } from 'path'
import childProcess from 'child_process'
async function clean(rootDir: string) {
const projectFilePath = join.bind(null, rootDir)
const pkgFilePath = join.bind(null, projectFilePath('node_modules'))
// 需要保留的文件列表
const reservedFiles = [
pkgFilePath('ajv-i18n/localize/es'),
pkgFilePath('svgo/.svgo.yml'),
pkgFilePath('.bin'),
].map((filePath) => {
const { dir, base } = parse(filePath)
return {
from: filePath,
to: join(dir, 'r_' + base.replace(/\./g, '')),
}
})
await Promise.all(
reservedFiles.map(async ({ from, to }) => {
await fs.rename(from, to).catch(() => {})
}),
)
childProcess.execSync(
`
cd ${rootDir}
shopt -s globstar
rm -rf \\
**/*.{map,lock,log,md,yml,yaml,ts,tsx,vue,txt} \\
**/.[!.]* \\
**/__*__ \\
**/{tsconfig.json,package-lock.json,Makefile,CHANGELOG} \\
**/*.{test,spec,es,esm}.* \\
**/{test,tests,example,examples,doc,docs,coverage,demo,umd,es,esm}/
`,
{ shell: '/bin/bash' },
)
await Promise.all(
reservedFiles.map(async ({ from, to }) => {
await fs.rename(to, from).catch(() => {})
}),
)
}
clean(process.argv[2])
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/fjc0k/docker-YApi.git
git@gitee.com:fjc0k/docker-YApi.git
fjc0k
docker-YApi
docker-YApi
master

搜索帮助