From 669a73232cbfac5f4f5009c904b21af90dfd572c Mon Sep 17 00:00:00 2001 From: Sean Sica <23294618+seansica@users.noreply.github.com> Date: Mon, 21 Oct 2024 11:30:39 -0400 Subject: [PATCH] fix(husky): use script-based workflow for installing husky to support ci integration --- .github/workflows/ci.yml | 4 +--- .husky/install.mjs | 6 ++++++ package.json | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 .husky/install.mjs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 34cdcd8..d52c1c0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -103,9 +103,7 @@ jobs: scope: '@mitre-attack' - name: Install dependencies - run: npm clean-install --omit=dev - env: - HUSKY: '0' # Disable Husky installation + run: npm clean-install - name: Verify the integrity of provenance attestations and registry signatures for installed dependencies run: npm audit signatures diff --git a/.husky/install.mjs b/.husky/install.mjs new file mode 100644 index 0000000..0bf841c --- /dev/null +++ b/.husky/install.mjs @@ -0,0 +1,6 @@ +// Skip Husky install in production and CI +if (process.env.NODE_ENV === 'production' || process.env.CI === 'true') { + process.exit(0); +} +const husky = (await import('husky')).default; +console.log(husky()); \ No newline at end of file diff --git a/package.json b/package.json index 86fb419..c7d81d1 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "test:interactive": "vitest", "export": "npm pack", "clean": "rm -rf test/**/*.js test/**/*.js.map test/**/*.d.ts test/**/*.ts.map src/**/*.js src/**/*.js.map src/**/*.d.ts", - "prepare": "husky", + "prepare": "node .husky/install.mjs", "lint": "npx eslint src", "lint:fix": "npm run lint -- --fix", "prettier": "npx prettier src --check",