-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathensure-push.ts
36 lines (29 loc) · 1.08 KB
/
ensure-push.ts
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
31
32
33
34
35
36
import { $ } from 'bun'
import colors from 'colors'
console.log(colors.inverse.yellow('[rsv-shared] Ensuring rsv-shared has no pending changes...'))
const packageFolder = '../rsv-shared'
// Step 1: Check for uncommitted changes (staged or unstaged)
const { stdout: status } = await $`git status --porcelain`.cwd(packageFolder).quiet()
const statusString = status.toString('utf-8')
if (statusString.length > 0) {
console.log(
colors.inverse.red(
'[rsv-shared] There are uncommitted changes! Commit or stash them before pushing.',
),
statusString,
)
process.exit(1)
}
// Step 2: Check for unpushed commits
const { stderr: pushStatus } = await $`git push --dry-run`.cwd(packageFolder).quiet()
const pushStatusString = pushStatus.toString('utf-8')
if (!pushStatusString.includes('Everything up-to-date')) {
console.log(
colors.inverse.red(
'[rsv-shared] rsv-shared has unpushed commits! Push them before pushing the website.',
),
pushStatusString,
)
process.exit(1)
}
console.log(colors.inverse.green('[rsv-shared] Everything is clean and pushed. All good!'))