build: fix pre-commit hook for symlinked self-dep and staged deletions (#621)
- 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.
This commit is contained in:
parent
01d826aea0
commit
739c0e049d
1 changed files with 6 additions and 3 deletions
|
|
@ -5,10 +5,12 @@
|
|||
* so examples always type-check against the latest local types.
|
||||
* See: https://github.com/npm/feedback/discussions/774
|
||||
*/
|
||||
import { cpSync, existsSync } from "fs";
|
||||
import { cpSync, existsSync, lstatSync } from "fs";
|
||||
|
||||
const target = "node_modules/@modelcontextprotocol/ext-apps";
|
||||
if (!existsSync(target)) process.exit(0);
|
||||
// If target is a symlink (e.g. to the repo root), dist is already current.
|
||||
if (lstatSync(target).isSymbolicLink()) process.exit(0);
|
||||
|
||||
cpSync("dist", `${target}/dist`, { recursive: true });
|
||||
cpSync("package.json", `${target}/package.json`);
|
||||
|
|
|
|||
Loading…
Reference in a new issue