MCPcopy Create free account
hub / github.com/chhoumann/quickadd / writeJson

Function writeJson

scripts/start-obsidian-e2e-instance.mjs:290–303  ·  view source on GitHub ↗
(filePath, value)

Source from the content-addressed store, hash-verified

288}
289
290async function writeJson(filePath, value) {
291 await fs.mkdir(path.dirname(filePath), { recursive: true, mode: 0o700 });
292 try {
293 const stat = await fs.lstat(filePath);
294 if (stat.isSymbolicLink() || !stat.isFile()) {
295 throw new Error(`${filePath} exists but is not a regular file.`);
296 }
297 } catch (error) {
298 if (error?.code !== "ENOENT") throw error;
299 }
300 await fs.writeFile(filePath, `${JSON.stringify(value, null, "\t")}\n`, {
301 mode: 0o600,
302 });
303}
304
305export async function launchObsidianInstance(options) {
306 // Validate (and create when absent) the profile tree here too, so a future

Callers 1

prepareObsidianProfileFunction · 0.70

Calls 1

dirnameMethod · 0.80

Tested by

no test coverage detected