Skip to content

Commit ced883b

Browse files
committed
Replaced --no-commit w/ --commit-msg ↞ [auto-sync from https://github.com/adamlui/ai-web-extensions/tree/main/utils/bump]
1 parent 9737396 commit ced883b

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

utils/bump/chatbots.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
// NOTE: Pass --cache to use cachePaths.chatbotPaths for faster init
66
// NOTE: Pass --dev to not use cachePaths.bumpUtils for latest ver
7-
// NOTE: Pass --no-<commit|push> to skip git commit/push
7+
// NOTE: Pass <--commit-msg|-m> "msg" to commit w/ msg
8+
// NOTE: Pass --no-push to skip git push
89

910
(async () => {
1011

@@ -15,7 +16,10 @@
1516
const config = {
1617
cacheMode: args.some(arg => arg.startsWith('--cache')),
1718
devMode: args.some(arg => arg.startsWith('--dev')),
18-
noCommit: args.some(arg => ['--no-commit', '-nc'].includes(arg)),
19+
commitMsg: (() => {
20+
const msgIdx = args.findIndex(arg => /^--?(?:m|commit-msg)$/.test(arg))
21+
return msgIdx != -1 && args[msgIdx +1] ? args[msgIdx +1].replace(/^"|"$/g, '') : null
22+
})(),
1923
noPush: args.some(arg => ['--no-push', '-np'].includes(arg))
2024
}
2125

@@ -90,29 +94,24 @@
9094
} else bump.log.success(`${filesUpdatedCnt} chatbot${pluralSuffix} bumped!`)
9195

9296
// ADD/COMMIT/PUSH bump(s)
93-
if (!config.noCommit) {
97+
if (config.commitMsg) {
9498
bump.log.working(`\nCommitting bump${pluralSuffix} to Git...\n`)
95-
96-
// Init commit msg
97-
let commitMsg = 'Bumped `@version`' ; const uniqueVers = {}
98-
Object.values(bumpedChatbots).forEach(({ newVer }) => { uniqueVers[newVer] = true })
99-
if (Object.keys(uniqueVers).length == 1)
100-
commitMsg += ` to \`${Object.keys(uniqueVers)[0]}\``
101-
102-
// git add/commit/push
10399
try {
104100
execSync('git add ./*.user.js')
105-
spawnSync('git', ['commit', '-n', '-m', commitMsg], { stdio: 'inherit', encoding: 'utf-8' })
101+
spawnSync('git', ['commit', '-n', '-m', config.commitMsg], { stdio: 'inherit', encoding: 'utf-8' })
106102
console.log('') // line break
107103
if (!config.noPush) {
108104
bump.log.working('\nPulling latest changes from remote to sync local repository...\n')
109105
execSync('git pull')
110106
bump.log.working(`\nPushing bump${pluralSuffix} to Git...\n`)
111107
execSync('git push')
112108
}
113-
bump.log.success(`Success! ${filesUpdatedCnt} chatbot${pluralSuffix} updated${
114-
!config.noCommit ? '/committed' : '' }${ !config.noPush ? '/pushed' : '' } to GitHub`)
109+
bump.log.success(`Success! ${filesUpdatedCnt} chatbot${pluralSuffix} updated/committed${
110+
!config.noPush ? '/pushed' : '' } to GitHub`)
115111
} catch (err) { bump.log.error('Git operation failed: ' + err.message) }
112+
} else {
113+
bump.log.info(`\nNo commit message provided. Skipping git operations.`)
114+
bump.log.info(`TIP: Use --commit-msg "msg" or -m "msg" to commit changes.`)
116115
}
117116

118117
// Final SUMMARY log

0 commit comments

Comments
 (0)