$ account observing
The `pre-commit` npm package automatically installs and manages git pre-commit hooks for Node.js projects. When installed as a devDependency, its `install.js` script locates the project's `.git` directory (including submodules and linked worktrees) and writes a shell wrapper into `.git/hooks/pre-commit`. Upon commit, that wrapper executes a crafted bash script (`hook`) that resolves the `pre-commit` package path via Node's `require.resolve` (supporting Yarn Plug'n'Play), then runs `index.js`. The `Hook` class in `index.js` reads the project's `package.json`, normalizes the `pre-commit`/`precommit` configuration into an ordered list of npm scripts, and executes them sequentially using `cross-spawn`. If any script fails with a non-zero exit code, the commit is aborted with a clear error message. The tool gracefully handles missing packages (exits 0 to avoid blocking commits), environment quirks (emacs/magit's `GIT_LITERAL_PATHSPECS`, SourceTree's path issues), and provides backup/restore of existing hooks. This is a single-purpose utility library with a clean Node.js core and a well-tested bash wrapper.