- link-self.mjs: skip when node_modules/@modelcontextprotocol/ext-apps is
a symlink (e.g. to the repo root). cpSync("dist", target/dist) was
failing with ERR_FS_CP_EINVAL because src and dest resolved to the
same path.
- .husky/pre-commit: capture staged files with --diff-filter=d so the
re-stage step doesn't fail with "pathspec did not match" on commits
(typically merges) that include deletions.
29 lines
1.3 KiB
Text
29 lines
1.3 KiB
Text
# Load Node.js environment for GUI apps (GitHub Desktop, etc.)
|
|
# that don't inherit shell PATH
|
|
export NVM_DIR="$HOME/.nvm"
|
|
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # nvm
|
|
[ -s "$HOME/.fnm/fnm" ] && eval "$(~/.fnm/fnm env)" # fnm
|
|
[ -s "$HOME/.volta/bin/volta" ] && export PATH="$HOME/.volta/bin:$PATH" # volta
|
|
[ -d "/opt/homebrew/bin" ] && export PATH="/opt/homebrew/bin:$PATH" # homebrew (macOS ARM)
|
|
[ -d "/usr/local/bin" ] && export PATH="/usr/local/bin:$PATH" # homebrew (macOS Intel)
|
|
|
|
# Verify no private registry URLs in package-lock.json
|
|
if grep -E '"resolved": "https?://' package-lock.json | grep -v registry.npmjs.org > /dev/null; then
|
|
echo "ERROR: package-lock.json contains non-npmjs.org URLs"
|
|
echo "Run: docker run --rm -i -v \$PWD:/src -w /src node:latest npm i --registry=https://registry.npmjs.org/"
|
|
exit 1
|
|
fi
|
|
|
|
# Capture staged files so we only re-stage what the user intended to commit
|
|
# (avoids sweeping unrelated WIP into the commit). --diff-filter=d skips
|
|
# deletions so the xargs git add below doesn't fail on removed paths.
|
|
STAGED=$(git diff --name-only --cached --diff-filter=d)
|
|
|
|
npm run build:all
|
|
npm run prettier:fix
|
|
|
|
# Re-stage originally-staged files (prettier may have reformatted them)
|
|
echo "$STAGED" | xargs -r git add
|
|
|
|
# Also stage generated files (regenerated by build:all from spec.types.ts)
|
|
git add src/generated/
|