-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4187878
commit eb3098a
Showing
7 changed files
with
49 additions
and
51 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
## Setting up Git Hooks | ||
|
||
After cloning the repository, set up the pre-commit hook by running the following commands: | ||
|
||
```sh | ||
touch .git/hooks/pre-commit | ||
chmod +x .git/hooks/pre-commit | ||
echo '#!/bin/sh\nnode scripts/check-changes.js' > .git/hooks/pre-commit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
const { execSync } = require('child_process'); | ||
|
||
function changed() { | ||
try { | ||
// Run Git commands to check for changes in the lib/rules directory | ||
const diffIndex = execSync('git diff-index --name-only -B -R -M -C HEAD lib/rules').toString().trim(); | ||
const lsFiles = execSync('git ls-files -t -o -m lib/rules').toString().trim(); | ||
|
||
// Return true if there are changes | ||
return diffIndex !== '' || lsFiles !== ''; | ||
} catch (error) { | ||
console.error('Error checking for changes:', error); | ||
return false; | ||
} | ||
} | ||
|
||
if (changed()) { | ||
try { | ||
// Run npm commands if there are changes | ||
execSync('npm run generate-rulesets', { stdio: 'inherit' }); | ||
execSync('npm run docs', { stdio: 'inherit' }); | ||
} catch (error) { | ||
console.error('Error running npm commands:', error); | ||
process.exit(1); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.