Skip to content

Commit e84f668

Browse files
committed
fix: only write to pnpm-workspace.yaml when changed, close #131
1 parent c7b09ad commit e84f668

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/io/pnpmWorkspaces.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,22 @@ export async function writePnpmWorkspace(
5959
if (!Object.keys(versions).length)
6060
return
6161

62+
let changed = false
63+
6264
if (catalogName === 'default') {
63-
pkg.raw.catalog = versions
65+
if (JSON.stringify(pkg.raw.catalog) !== JSON.stringify(versions)) {
66+
pkg.raw.catalog = versions
67+
changed = true
68+
}
6469
}
6570
else {
6671
pkg.raw.catalogs ??= {}
67-
pkg.raw.catalogs[catalogName] = versions
72+
if (pkg.raw.catalogs[catalogName] !== versions) {
73+
pkg.raw.catalogs[catalogName] = versions
74+
changed = true
75+
}
6876
}
6977

70-
await fs.writeFile(pkg.filepath, YAML.dump(pkg.raw), 'utf-8')
78+
if (changed)
79+
await fs.writeFile(pkg.filepath, YAML.dump(pkg.raw), 'utf-8')
7180
}

0 commit comments

Comments
 (0)