Update publish.mjs

This commit is contained in:
JFH
2025-12-07 19:49:35 +01:00
parent 76c8e42cb2
commit 35b3d62df1

View File

@@ -71,6 +71,16 @@ function run (command) {
execSync(command, { stdio: 'inherit', cwd: rootDir })
}
function hasStagedChanges () {
try {
execSync('git diff --cached --quiet', { cwd: rootDir, stdio: 'ignore' })
return false
} catch (error) {
if (error.status === 1) return true
throw error
}
}
async function main () {
const rootPackage = readJson(rootPackagePath)
const workspacePackages = loadWorkspacePackagePaths()
@@ -121,7 +131,11 @@ async function main () {
...workspacePackages
]
run(`git add ${filesToStage.map(quoteArg).join(' ')}`)
if (hasStagedChanges()) {
run(`git commit -m ${quoteArg(releaseName)}`)
} else {
console.log('No changes to commit; skipping git commit.')
}
run(`git tag ${quoteArg(releaseName)}`)
console.log('\nPublishing packages to npm...')