fix(qmd): write index.yml atomically

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Julian lechnerandClaude Opus 5.5 committed 2026-10-08 12:42:40 +02:00
1 parent ced6d8f119
commit abface2293
3 files changed
+23 -10

No files matched your search

+4 -5
View File
@@ -1,8 +1,8 @@
// shared/qmd/qmd-config.mjs — edits only the models: block of QMD's index.yml.
import { existsSync, readFileSync, writeFileSync, mkdirSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { existsSync, readFileSync } from 'node:fs';
import { join } from 'node:path';
import { pathToFileURL } from 'node:url';
import { MODELS, qmdConfigPath, qmdPackageDir } from './qmd-lib.mjs';
import { MODELS, qmdConfigPath, qmdPackageDir, writeTextAtomic } from './qmd-lib.mjs';
export function setModels(text, YAML) {
const document = YAML.parseDocument(text || '');
@@ -49,8 +49,7 @@ async function main(action, argument) {
if (mapping === undefined) throw new Error('restore-models needs a JSON value');
next = restoreModels(current, YAML, mapping);
} else next = unsetModels(current, YAML);
mkdirSync(dirname(path), { recursive: true });
writeFileSync(path, next);
writeTextAtomic(path, next);
}
if (import.meta.url === pathToFileURL(process.argv[1] || '').href) {