-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsync-version.mjs
30 lines (25 loc) · 878 Bytes
/
sync-version.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { readFileSync, writeFileSync } from 'node:fs'
const packageJson = JSON.parse(readFileSync('./package.json', 'utf8'))
const jsrJsonPath = './jsr.json'
const jsrJson = JSON.parse(readFileSync(jsrJsonPath, 'utf8'))
let hasChanges = false
if (jsrJson.version !== packageJson.version) {
jsrJson.version = packageJson.version
console.log(`Updated jsr.json version to ${packageJson.version}`)
hasChanges = true
}
if (
JSON.stringify(jsrJson.peerDependencies)
!== JSON.stringify(packageJson.peerDependencies)
) {
jsrJson.peerDependencies = packageJson.peerDependencies
console.log('Updated jsr.json peerDependencies to match package.json')
hasChanges = true
}
if (hasChanges) {
writeFileSync(jsrJsonPath, JSON.stringify(jsrJson, null, 2), 'utf8')
console.log('jsr.json updated successfully.')
}
else {
console.log('jsr.json is already up-to-date.')
}