|
9 | 9 | (async () => { |
10 | 10 |
|
11 | 11 | // Parse ARGS |
12 | | - const args = process.argv.slice(2), |
13 | | - chromiumOnly = args.some(arg => /chrom/i.test(arg)), |
14 | | - ffOnly = args.some(arg => /f{2}/i.test(arg)), |
15 | | - noCommit = args.some(arg => ['--no-commit', '-nc'].includes(arg)), |
16 | | - noPush = args.some(arg => ['--no-push', '-np'].includes(arg)) |
| 12 | + const args = process.argv.slice(2) |
| 13 | + const config = { |
| 14 | + chromiumOnly: args.some(arg => /chrom/i.test(arg)), |
| 15 | + ffOnly: args.some(arg => /f{2}/i.test(arg)), |
| 16 | + noCommit: args.some(arg => ['--no-commit', '-nc'].includes(arg)), |
| 17 | + noPush: args.some(arg => ['--no-push', '-np'].includes(arg)) |
| 18 | + } |
17 | 19 |
|
18 | 20 | // Import LIBS |
19 | 21 | const fs = require('fs'), |
|
40 | 42 |
|
41 | 43 | // Check latest commit for extension changes if forcible platform flag not set |
42 | 44 | const platformManifestPath = path.dirname(manifestPath) |
43 | | - if (!chromiumOnly && !ffOnly) { |
| 45 | + if (!config.chromiumOnly && !config.ffOnly) { |
44 | 46 | console.log(`Checking last commit details for ${platformManifestPath}...`) |
45 | 47 | try { |
46 | 48 | const latestCommitMsg = spawnSync('git', |
|
53 | 55 | } catch (err) { bump.log.error('Error checking git history\n') } |
54 | 56 | } |
55 | 57 |
|
56 | | - console.log(`Bumping version in ${chromiumOnly ? 'Chromium' : ffOnly ? 'Firefox' : ''} manifest...`) |
| 58 | + console.log(`Bumping version in ${ |
| 59 | + config.chromiumOnly ? 'Chromium' : config.ffOnly ? 'Firefox' : ''} manifest...`) |
57 | 60 | const { oldVer, newVer } = bump.bumpDateVer({ filePath: manifestPath }) |
58 | 61 | bumpedManifests[`${platformManifestPath}/manifest.json`] = `${oldVer};${newVer}` |
59 | 62 | } |
|
66 | 69 |
|
67 | 70 |
|
68 | 71 | // ADD/COMMIT/PUSH bump(s) |
69 | | - if (!noCommit) { |
| 72 | + if (!config.noCommit) { |
70 | 73 | bump.log.working(`\nCommitting bump${pluralSuffix} to Git...\n`) |
71 | 74 |
|
72 | 75 | // Init commit msg |
|
80 | 83 | try { |
81 | 84 | execSync('git add ./**/manifest.json') |
82 | 85 | spawnSync('git', ['commit', '-n', '-m', commitMsg], { stdio: 'inherit', encoding: 'utf-8' }) |
83 | | - if (!noPush) { |
| 86 | + if (!config.noPush) { |
84 | 87 | bump.log.working('\nPulling latest changes from remote to sync local repository...\n') |
85 | 88 | execSync('git pull') |
86 | 89 | bump.log.working('\nPushing bump${pluralSuffix} to Git...\n') |
87 | 90 | execSync('git push') |
88 | 91 | } |
89 | 92 | bump.log.success(`Success! ${Object.keys(bumpedManifests).length} manifest${pluralSuffix} updated${ |
90 | | - !noCommit ? '/committed' : '' }${ !noPush ? '/pushed' : '' } to GitHub`) |
| 93 | + !config.noCommit ? '/committed' : '' }${ !config.noPush ? '/pushed' : '' } to GitHub`) |
91 | 94 | } catch (err) { bump.log.error('Git operation failed: ' + err.message) } |
92 | 95 | } |
93 | 96 |
|
|
0 commit comments