chore: 🔧 Update files
This commit is contained in:
parent
a26f87f9d4
commit
b744a3dd10
1 changed files with 58 additions and 12 deletions
|
|
@ -36,22 +36,67 @@ async function findCommitsScript(): Promise<string | null> {
|
|||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* Run dev-publish after successful commit+push
|
||||
*/
|
||||
async function runDevPublish(cwd: string): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
console.log(colors.blue('\n[bitch] Running dev-publish...'))
|
||||
|
||||
// Find dev-publish wrapper script
|
||||
const devPublishScript = join(cwd, '../../scripts/publishing/dev-publish.sh')
|
||||
|
||||
const child = spawn('bash', [devPublishScript, cwd], {
|
||||
stdio: 'inherit',
|
||||
env: process.env,
|
||||
})
|
||||
|
||||
child.on('close', (code) => {
|
||||
if (code === 0) {
|
||||
console.log(colors.green('[bitch] Dev version published successfully'))
|
||||
resolve()
|
||||
} else {
|
||||
console.log(colors.yellow(`[bitch] Dev-publish exited with code ${code}`))
|
||||
resolve() // Don't fail the whole command
|
||||
}
|
||||
})
|
||||
|
||||
child.on('error', (err) => {
|
||||
console.log(colors.yellow(`[bitch] Dev-publish error: ${err.message}`))
|
||||
resolve() // Don't fail the whole command
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the commits script with the 'commit' subcommand
|
||||
*/
|
||||
function runCommit(scriptPath: string, args: string[]): void {
|
||||
const child = spawn('bash', [scriptPath, 'commit', ...args], {
|
||||
stdio: 'inherit',
|
||||
env: process.env,
|
||||
})
|
||||
async function runCommit(scriptPath: string, args: string[], shouldPush: boolean): Promise<void> {
|
||||
const cwd = process.cwd()
|
||||
|
||||
child.on('close', (code) => {
|
||||
process.exit(code || 0)
|
||||
})
|
||||
return new Promise((resolve, reject) => {
|
||||
const child = spawn('bash', [scriptPath, 'commit', ...args], {
|
||||
stdio: 'inherit',
|
||||
env: process.env,
|
||||
})
|
||||
|
||||
child.on('error', (err) => {
|
||||
logError(`Failed to run commit: ${err.message}`)
|
||||
process.exit(1)
|
||||
child.on('close', async (code) => {
|
||||
if (code === 0 && shouldPush) {
|
||||
// After successful commit+push, run dev-publish
|
||||
try {
|
||||
await runDevPublish(cwd)
|
||||
} catch (err) {
|
||||
// Dev-publish failure shouldn't fail the commit
|
||||
console.log(colors.yellow('[bitch] Dev-publish failed, but commit succeeded'))
|
||||
}
|
||||
}
|
||||
process.exit(code || 0)
|
||||
})
|
||||
|
||||
child.on('error', (err) => {
|
||||
logError(`Failed to run commit: ${err.message}`)
|
||||
process.exit(1)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -99,7 +144,8 @@ export function createCommitCommand(): Command {
|
|||
process.exit(1)
|
||||
}
|
||||
|
||||
runCommit(scriptPath, args)
|
||||
const shouldPush = options.push !== false
|
||||
await runCommit(scriptPath, args, shouldPush)
|
||||
})
|
||||
|
||||
return cmd
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue