algometrix_second_brain_bui.../scripts/vault-root.js
algometrix e22cc920b7 Initial release: AI Explainer plugin for Obsidian
Generate linked explanation notes from selections using Claude Code,
Gemini, Codex, or a local Ollama model. Includes 23 sample note modes,
inline enhancement actions, batch generation, a config-driven modes
system, cross-platform installers, and vault repair scripts.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-15 02:51:45 -04:00

27 lines
895 B
JavaScript

// Shared vault path resolution for all fix scripts.
// The vault path comes from the first non-flag CLI argument, or from the
// OBSIDIAN_VAULT environment variable if no argument is given.
const fs = require('fs');
const path = require('path');
function resolveVaultRoot() {
const arg = process.argv.slice(2).find(a => !a.startsWith('--'));
const root = arg || process.env.OBSIDIAN_VAULT;
if (!root) {
const script = path.basename(process.argv[1] || 'fix-script.js');
console.error(`Usage: node scripts/${script} <vault-path> [--fix]`);
console.error('Or set the OBSIDIAN_VAULT environment variable to your vault path.');
process.exit(1);
}
if (!fs.existsSync(root) || !fs.statSync(root).isDirectory()) {
console.error(`Vault path is not a directory: ${root}`);
process.exit(1);
}
return path.resolve(root);
}
module.exports = { resolveVaultRoot };