1 import util from "node:util"
2 import { exec } from "child_process"
3 import path from "node:path"
4
5 const promiseExec = util.promisify(exec)
6
7 async function main() {
8 // check if there are any changes in diff
9 const diffFiles = (await promiseExec(`git diff --name-only`)).stdout
10 .toString()
11 .split("\n")
12 .filter(Boolean)
13
14 if (!diffFiles.length) {
15 console.log("No files were changed, skipping generating changeset...")
16 return
17 }
18
19 // run changeset
20 await promiseExec(`yarn changeset --empty`, {
21 cwd: path.resolve("..", "..", "..", ".."),
22 })
23 console.log("Generated changeset.")
24 }
25
26 void main()