()
| 809 | |
| 810 | let _gbrainAvailability: boolean | null = null; |
| 811 | function gbrainAvailable(): boolean { |
| 812 | if (_gbrainAvailability !== null) return _gbrainAvailability; |
| 813 | try { |
| 814 | // Probe `--help` for the `import` subcommand. gbrain v0.20.0+ ships |
| 815 | // `import <dir>` (batch markdown import via path-authoritative slugs). |
| 816 | // If absent, we surface a single clean error here rather than failing |
| 817 | // the whole stage with a confusing usage message from gbrain itself. |
| 818 | // `gbrain --help` probes only CLI availability, not DB connectivity, so |
| 819 | // it doesn't strictly need DATABASE_URL. But routing through the helper |
| 820 | // keeps the invariant test from chasing exceptions per call site. |
| 821 | const help = execGbrainText(["--help"], { timeout: 5000 }); |
| 822 | _gbrainAvailability = /^\s+import\s/m.test(help); |
| 823 | } catch { |
| 824 | _gbrainAvailability = false; |
| 825 | } |
| 826 | return _gbrainAvailability; |
| 827 | } |
| 828 | |
| 829 | /** |
| 830 | * Build the markdown body with YAML frontmatter (title/type/tags) injected. |
no test coverage detected