Skip to content

Commit 4c11069

Browse files
committed
fix(core): 修改cup清理文件命令
1 parent de54f72 commit 4c11069

File tree

7 files changed

+77
-13
lines changed

7 files changed

+77
-13
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ npm i -g code-genius
1818

1919
## 终端命令
2020

21-
| 命令 | 参数 | 功能描述 |
22-
| ------ | ---------------- | ---------------------------------------------- |
23-
| cm | --noEmoji | 帮助生成规范的 git 提交内容 |
24-
| cmv | -- | 帮助验证 git commit 的内容是否符合规范 |
25-
| cup | --ignore <match> | 清理运行时生成的文件 |
26-
| ihooks | -- | 使用且有修改 simple-git-hooks 后需要重新初始化 |
21+
| 命令 | 参数 | 功能描述 |
22+
| ------ | --------------- | ---------------------------------------------- |
23+
| cm | --noEmoji | 帮助生成规范的 git 提交内容 |
24+
| cmv | -- | 帮助验证 git commit 的内容是否符合规范 |
25+
| cup | --ignore <path> | 清理运行时生成的文件 |
26+
| ihooks | -- | 使用且有修改 simple-git-hooks 后需要重新初始化 |
2727

2828
## API
2929

package-lock.json

Lines changed: 48 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
"build": "unbuild",
4242
"stub": "unbuild --stub",
4343
"release": "release-it",
44-
"cm": "cg cm --noEmoji",
45-
"cup": "cg cup --ignore '**/dist'"
44+
"cm": "cross-env CG_DEBUG=activation cg cm --noEmoji",
45+
"cup": "cross-env CG_DEBUG=activation cg cup --ignore ./dist --ignore ./node_modules"
4646
},
4747
"keywords": [
4848
"CodeGenius",
@@ -54,6 +54,8 @@
5454
],
5555
"devDependencies": {
5656
"@release-it/conventional-changelog": "^7.0.1",
57+
"@types/rimraf": "^4.0.5",
58+
"cross-env": "^7.0.3",
5759
"release-it": "^16.1.5",
5860
"simple-git-hooks": "^2.9.0",
5961
"typescript": "^5.2.2",

src/command/cheanup.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
import { rimraf } from "rimraf";
2+
import { green } from "kolorist";
3+
import { ACTIVATION } from "../shared/config";
24

35
export const cleanUp = async (paths: string[]) => {
4-
await rimraf(paths, { glob: true });
5-
};
6+
if (ACTIVATION) {
7+
console.log(`${green("cleanUp 参数信息: \n")}`);
8+
console.table(paths);
9+
}
10+
await rimraf(paths, { glob: false });
11+
};

src/command/git-commit.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import enquirer from "enquirer";
2+
import { green } from "kolorist";
23
import { CommitScope, CommitType } from "../shared/types";
34
import { execCommand } from "../shared";
4-
5+
import { ACTIVATION } from "../shared/config";
56
interface PromptResult {
67
type: string;
78
scope: string;
@@ -17,6 +18,12 @@ export const gitCommit = async (
1718
scopes: Array<CommitScope>,
1819
options: GitCommitOptions
1920
) => {
21+
if (ACTIVATION) {
22+
console.log(`${green("gitCommit 参数信息: \n")}`);
23+
console.table(types);
24+
console.table(scopes);
25+
console.table(options);
26+
}
2027
const { enableEmoji } = options;
2128
const typesChoices = types.map(({ emoji, code, description }) => {
2229
const formatCode = `${code}:`.padEnd(12);

src/setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const setupSet: SetupSet = {
3535
cupSetup: (cli: CAC) => {
3636
cli
3737
.command("cup", "Clean files generated during runtime")
38-
.option("--ignore <match>", "ignore match", {
38+
.option("--ignore <path>", "ignore path", {
3939
default: [...cleanUpDirs],
4040
})
4141
.action(async (options) => {

src/shared/config.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { CommitScope, CommitType } from "./types";
22

3-
43
export const gitCommitTypes: Array<CommitType> = [
54
{
65
emoji: "🎉",
@@ -97,3 +96,5 @@ export const cleanUpDirs = [
9796
];
9897

9998
export const cwd = process.cwd();
99+
100+
export const ACTIVATION = process.env.CG_DEBUG === "activation";

0 commit comments

Comments
 (0)