Skip to content

getNanoStagedConfig

Resolves the nano-staged configuration to use, honoring a per-developer opt-out.

Loads a gitignored .env if present (via Node’s own process.loadEnvFile, so it behaves the same on every platform and shell), 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.

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.

Import:

import { getNanoStagedConfig } from 'obsidian-dev-utils/script-utils/nano-staged-config';

Signature:

function getNanoStagedConfig(): Record<string, string[]>

Returns: Record<string, string[]> — The nano-staged task configuration. Does not return when the opt-out is active.