script-utils/nano-staged-config
Shared nano-staged configuration for pre-commit hooks.
Functions
Section titled “Functions”| Function | Description |
|---|---|
| getNanoStagedConfig | Resolves the nano-staged configuration to use, honoring a per-developer opt-out. Loads a gitignored .env if present, then — when NANO_STAGED is set to an off value (0, false, off, or no) — prints a notice and exits the process successfully so the pre-commit checks are skipped. This mirrors husky’s own HUSKY=0 switch, but scoped to the nano-staged step (so the commit-msg hook still runs). Otherwise it returns obsidianDevUtilsConfig. NANO_STAGED is not an npm script, so it carries its own switch rather than the script-name-derived one every npm script gets — but both share the same notion of an off value, via isEnvVariableOff. This is a function rather than module-level code so importing the package barrel never triggers the .env read or the process exit; call it from the thin scripts/nano-staged-config.ts entry. Resolving the package manager is the one thing that does run at module scope, and it does neither of those two things — it only probes for a lockfile. |
Variables
Section titled “Variables”| Variable | Description |
|---|---|
| obsidianDevUtilsConfig | Nano-staged configuration that runs file-based lint, format, and spellcheck on staged files. Only includes tools that can operate on individual files. Whole-project checks (TypeScript compilation, unit tests) are left to CI. Commands run through the package manager that owns the tree — npm run ... --, bun run ... --, and so on — so nano-staged file paths are forwarded as CLI arguments. |