forked from Qortal/q-blog
26 lines
726 B
Bash
Executable File
26 lines
726 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
if ! command -v jq >/dev/null 2>&1; then
|
|
echo "jq is required" >&2
|
|
exit 1
|
|
fi
|
|
|
|
if [[ ! -f package.json ]]; then
|
|
echo "package.json not found" >&2
|
|
exit 1
|
|
fi
|
|
|
|
tmp="$(mktemp)"
|
|
jq '.
|
|
| .scripts = (.scripts // {})
|
|
| .scripts.lint = (.scripts.lint // "eslint .")
|
|
| .scripts["format"] = (.scripts["format"] // "prettier --check .")
|
|
| .scripts["format:write"] = (.scripts["format:write"] // "prettier --write .")
|
|
| .scripts.test = (.scripts.test // "vitest")
|
|
| .scripts["test:run"] = (.scripts["test:run"] // "vitest run")
|
|
| .scripts.typecheck = (.scripts.typecheck // "tsc -p tsconfig.json -noEmit")
|
|
' package.json > "$tmp"
|
|
mv "$tmp" package.json
|
|
echo "Scripts patched."
|