Skip to content

Commit a4d144a

Browse files
committed
always validate toml before writing to disk
1 parent 5588375 commit a4d144a

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

packages/cli-kit/src/public/node/toml/toml-file.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ export class TomlFile {
6969
const patches = flattenToPatchEntries(changes)
7070
const raw = await readFile(this.path)
7171
const updated = updateTomlValues(raw, patches)
72+
const parsed = this.decode(updated)
7273
await writeFile(this.path, updated)
73-
this.content = this.decode(updated)
74+
this.content = parsed
7475
}
7576

7677
/**
@@ -86,8 +87,9 @@ export class TomlFile {
8687
const keys = keyPath.split('.')
8788
const raw = await readFile(this.path)
8889
const updated = updateTomlValues(raw, [[keys, undefined]])
90+
const parsed = this.decode(updated)
8991
await writeFile(this.path, updated)
90-
this.content = this.decode(updated)
92+
this.content = parsed
9193
}
9294

9395
/**
@@ -102,6 +104,7 @@ export class TomlFile {
102104
*/
103105
async replace(content: JsonMapType): Promise<void> {
104106
const encoded = encodeToml(content)
107+
this.decode(encoded)
105108
await writeFile(this.path, encoded)
106109
this.content = content
107110
}

0 commit comments

Comments
 (0)