小编Kor*_*rad的帖子

与 husky 一起使用时多次运行 lint-staged

当我npx lint-staged在终端中使用时,一切看起来都正常。

\n

例如:

\n
PS E:\\Projects\\sample-project> git status\nOn branch main\nYour branch is up to date with \'origin/main\'.\n\nChanges to be committed:\n  (use "git restore --staged <file>..." to unstage)\n        new file:   .husky/commit-msg\n        new file:   .husky/pre-commit\n        new file:   .lintstagedrc.json\n        modified:   .prettierrc\n        new file:   commitlint.config.js\n        modified:   nx.json\n        modified:   package-lock.json\n        modified:   package.json\n\nPS E:\\Projects\\sample-project> npx lint-staged\n\xe2\x88\x9a Preparing lint-staged...\n\xe2\x88\x9a Running tasks for staged files...\n\xe2\x88\x9a Applying modifications from tasks...\n\xe2\x88\x9a Cleaning up temporary files...\nPS E:\\Projects\\sample-project> \n
Run Code Online (Sandbox Code Playgroud)\n

但是当我的哈士奇pre-commit钩子运行相同的命令时:

\n
#!/usr/bin/env sh\n. "$(dirname "$0")/_/husky.sh"\n\nnpx lint-staged\n …
Run Code Online (Sandbox Code Playgroud)

javascript configuration husky lint-staged

9
推荐指数
1
解决办法
3123
查看次数

如何使用 @nestjs/terminus 为 Prisma 创建自定义健康检查?

由于@nestjs/terminus不为 Prisma 提供健康检查,我尝试根据他们的Mongoose 健康检查创建它。

当我尝试时:

import * as Prisma from 'prisma';
...
...
  private getContextConnection(): any | null {
    const {
      getConnectionToken,
      // eslint-disable-next-line @typescript-eslint/no-var-requires
    } = require('prisma') as typeof Prisma;

    try {
      return this.moduleRef.get(getConnectionToken('DatabaseConnection') as string, {
        strict: false,
      });
    } catch (err) {
      return null;
    }
  }
...
...
    const connection = options.connection || this.getContextConnection();

    if (!connection) {
      throw new ConnectionNotFoundError(
        this.getStatus(key, isHealthy, {
          message: 'Connection provider not found in application context',
        }),
      ); …
Run Code Online (Sandbox Code Playgroud)

nestjs prisma health-check

8
推荐指数
2
解决办法
5488
查看次数