(filePath, value)
| 288 | } |
| 289 | |
| 290 | async 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 | |
| 305 | export async function launchObsidianInstance(options) { |
| 306 | // Validate (and create when absent) the profile tree here too, so a future |
no test coverage detected