1

我正在使用 commitlint、husky 和 ​​lint-staged 来验证我的 C# 项目的提交消息和格式。package.json 文件看起来像

{
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged --relative"
    }
  },
  "lint-staged": {
    "*.cs": "dotnet format ./MyProject/TheSolution.sln --include"
  },
  "devDependencies": {
    "@commitlint/cli": "^12.1.1",
    "@commitlint/config-conventional": "^12.1.1",
    "husky": "^6.0.0",
    "lint-staged": "^10.5.4"
  },
  "scripts": {
    "prepare": "husky install"
  }
}

在提交之前,我还将确保

  • 所有软件包都可用=>dotnet restore
  • 项目被编译=>dotnet build --no-restore
  • 所有测试都通过 =>dotnet test --no-build --verbosity normal

我必须在哪里添加这些命令?有没有办法传入一个数组,其中包含要按顺序运行的所有命令?还是我必须使用这个?

"pre-commit": "dotnet restore ./MyProject && dotnet build --no-restore ./MyProject && dotnet test --no-build --verbosity normal ./MyProject && lint-staged --relative"

4

0 回答 0