зеркало из https://github.com/mozilla/fxa.git
chore(audit): only audit once per day
This commit is contained in:
Родитель
9fbd1697a8
Коммит
35af352758
|
@ -26,6 +26,7 @@ secrets.json
|
|||
.es5cache
|
||||
/artifacts
|
||||
/packages/test.list
|
||||
.last-audit
|
||||
|
||||
# Dependencies
|
||||
**/node_modules
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
FILE=.last-audit
|
||||
NOW=$(date +%s)
|
||||
|
||||
function run_audit() {
|
||||
npm run audit
|
||||
echo $NOW > $FILE
|
||||
}
|
||||
|
||||
if [ -f "$FILE" ]; then
|
||||
THRESHOLD=86400 # 24 hours
|
||||
EXISTING=$(< $FILE)
|
||||
DIFFERENCE=$(($NOW - $EXISTING))
|
||||
|
||||
if [ "$DIFFERENCE" -ge "$THRESHOLD" ]; then
|
||||
run_audit
|
||||
else
|
||||
echo "Audited within the last 24 hours, skipping"
|
||||
fi
|
||||
else
|
||||
echo "Creating an inital audit record"
|
||||
run_audit
|
||||
fi
|
|
@ -68,7 +68,7 @@
|
|||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "lint-staged",
|
||||
"pre-push": "npm run audit"
|
||||
"pre-push": "_scripts/audit.sh"
|
||||
}
|
||||
},
|
||||
"lint-staged": {
|
||||
|
|
Загрузка…
Ссылка в новой задаче