|
4 | 4 |
|
5 | 5 | // NOTE: Pass --cache to use cachePaths.chatbotPaths for faster init |
6 | 6 | // 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 |
8 | 9 |
|
9 | 10 | (async () => { |
10 | 11 |
|
|
15 | 16 | const config = { |
16 | 17 | cacheMode: args.some(arg => arg.startsWith('--cache')), |
17 | 18 | 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 | + })(), |
19 | 23 | noPush: args.some(arg => ['--no-push', '-np'].includes(arg)) |
20 | 24 | } |
21 | 25 |
|
|
90 | 94 | } else bump.log.success(`${filesUpdatedCnt} chatbot${pluralSuffix} bumped!`) |
91 | 95 |
|
92 | 96 | // ADD/COMMIT/PUSH bump(s) |
93 | | - if (!config.noCommit) { |
| 97 | + if (config.commitMsg) { |
94 | 98 | 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 |
103 | 99 | try { |
104 | 100 | 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' }) |
106 | 102 | console.log('') // line break |
107 | 103 | if (!config.noPush) { |
108 | 104 | bump.log.working('\nPulling latest changes from remote to sync local repository...\n') |
109 | 105 | execSync('git pull') |
110 | 106 | bump.log.working(`\nPushing bump${pluralSuffix} to Git...\n`) |
111 | 107 | execSync('git push') |
112 | 108 | } |
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`) |
115 | 111 | } 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.`) |
116 | 115 | } |
117 | 116 |
|
118 | 117 | // Final SUMMARY log |
|
0 commit comments