diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 10578122..271c11c6 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -57,7 +57,8 @@ repos: - id: next-lint-website name: Lint website files: ^website/ + exclude: ^website/node_modules/ types_or: [javascript, jsx, ts, tsx] - language: system + language: node pass_filenames: false - entry: bash -c "cd website && npm install && npm run lint" + entry: website/next-lint.js diff --git a/website/next-lint.js b/website/next-lint.js new file mode 100755 index 00000000..0b3a5c90 --- /dev/null +++ b/website/next-lint.js @@ -0,0 +1,24 @@ +#!/usr/bin/env node +const { spawnSync } = require("child_process"); +async function npmLint() { + const spawnOption = { + shell: true, + env: process.env, + stdio: "inherit", + cwd: "./website", + }; + let npmInstall; + let npmRunLint; + try { + npmInstall = await spawnSync("npm", ["install"], spawnOption); + if (npmInstall.status !== 0) { + process.exit(npmInstall.status); + } + npmRunLint = await spawnSync("npm", ["run lint"], spawnOption); + process.exit(npmRunLint.status); + } catch (error) { + console.error(error); + process.exit(1); + } +} +npmLint();