Skip to content

Commit 362497f

Browse files
authored
fix: keep NOTICE.txt accurate in Renovate PRs and local dev (#252) (#287)
1 parent 1f2e9ba commit 362497f

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

.githooks/pre-commit

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
# Regenerate NOTICE.txt whenever package.json or package-lock.json is staged.
3+
# This keeps the file accurate for both manual dependency bumps and automated
4+
# tool runs (e.g. `npm install`) that stage lockfile changes.
5+
6+
if git diff --cached --name-only | grep -qE '^package(-lock)?\.json$'; then
7+
echo "package.json or package-lock.json changed — regenerating NOTICE.txt..."
8+
node scripts/generate-notice.mjs
9+
git add NOTICE.txt
10+
fi

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"packages/*"
1111
],
1212
"scripts": {
13+
"prepare": "git config core.hooksPath .githooks || true",
1314
"build": "node --max-old-space-size=6144 node_modules/typescript/bin/tsc -b",
1415
"postbuild": "node -e \"const {unlinkSync,readdirSync,existsSync}=require('fs'),{join}=require('path'),d='dist/es/apis/schemas';if(existsSync(d))readdirSync(d).filter(f=>/\\.(d\\.ts|d\\.ts\\.map|js\\.map)$/.test(f)).forEach(f=>unlinkSync(join(d,f)))\"",
1516
"test": "npm run build && npm run test:unit && npm run test:license",

renovate.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,10 @@
22
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
33
"extends": [
44
"local>elastic/renovate-config"
5-
]
5+
],
6+
"postUpgradeTasks": {
7+
"commands": ["node scripts/generate-notice.mjs"],
8+
"fileFilters": ["NOTICE.txt"],
9+
"executionMode": "branch"
10+
}
611
}

0 commit comments

Comments
 (0)