fix: clean vault/vaults output in n8n
Build and Push Docker Container / build-and-push (push) Successful in 4m46s

- Parse vaults stdout into structured {name,path} pairs

- For vault/vaults, return parsed JSON directly (no stdout wrapper)

- Keep minimal output for all operations: stdout or parsed_stdout

- Bump n8n node package to 0.2.3
This commit is contained in:
2026-06-24 12:25:27 +02:00
parent a953214c20
commit f3762eec82
4 changed files with 27 additions and 16 deletions
@@ -144,14 +144,12 @@ function extractErrorMessage(body: unknown): string {
}
function maybeParseStdout(result: ObsidianCommandResult): IDataObject | undefined {
const lastArg = result.command[result.command.length - 1];
if (lastArg !== 'vault' && lastArg !== 'vaults') return undefined;
const cmd = result.command;
const hasVault = cmd.includes('vault');
const hasVaults = cmd.includes('vaults');
if (!hasVault && !hasVaults) return undefined;
// Obsidian CLI prints either:
// vault:
// key<TAB>value\nkey<TAB>value\n...
// vaults:
// often one vault per line (names) or a similar tabular output.
const lines = (result.stdout || '')
.split(/\r?\n/)
.map((l) => l.trim())
@@ -159,11 +157,24 @@ function maybeParseStdout(result: ObsidianCommandResult): IDataObject | undefine
if (!lines.length) return undefined;
const isKv = lines.some((l) => l.includes('\t'));
if (!isKv && lastArg === 'vaults') {
return { vaults: lines };
// vaults output is typically a 2-col tabular format: <name>\t<containerPath>
if (hasVaults) {
const vaults: Array<{ name: string; path: string }> = [];
for (const line of lines) {
const parts = line.split('\t');
if (parts.length < 2) continue;
const name = parts[0].trim();
const path = parts.slice(1).join('\t').trim();
if (!name || !path) continue;
vaults.push({ name, path });
}
// Fallback: if parsing failed, return raw lines
if (!vaults.length) return { vaults: lines };
return { vaults };
}
// vault output is often key\tvalue pairs
const kv: Record<string, string | number> = {};
for (const line of lines) {
const parts = line.split('\t');