|
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'), |
|
34 | 36 | // Init manifest PATHS |
35 | 37 | const chromiumManifestPath = 'chromium/extension/manifest.json', |
36 | 38 | ffManifestPath = 'firefox/extension/manifest.json' |
37 | | - const manifestPaths = chromiumOnly ? [chromiumManifestPath].filter(p => /chrom/i.test(p)) |
38 | | - : ffOnly ? [ffManifestPath].filter(p => /firefox/i.test(p)) |
| 39 | + const manifestPaths = config.chromiumOnly ? [chromiumManifestPath].filter(p => /chrom/i.test(p)) |
| 40 | + : config.ffOnly ? [ffManifestPath].filter(p => /firefox/i.test(p)) |
39 | 41 | : [chromiumManifestPath, ffManifestPath] |
40 | 42 | // BUMP versions |
41 | 43 | const bumpedManifests = {} |
42 | 44 | for (const manifestPath of manifestPaths) { |
43 | 45 |
|
44 | 46 | // Check latest commit for extension changes if forcible platform flag not set |
45 | 47 | const platformManifestPath = path.dirname(manifestPath) |
46 | | - if (!chromiumOnly && !ffOnly) { |
| 48 | + if (!config.chromiumOnly && !config.ffOnly) { |
47 | 49 | console.log(`Checking last commit details for ${platformManifestPath}...`) |
48 | 50 | try { |
49 | 51 | const latestCommitMsg = spawnSync('git', |
|
56 | 58 | } catch (err) { bump.log.error('Error checking git history\n') } |
57 | 59 | } |
58 | 60 |
|
59 | | - console.log(`Bumping version in ${chromiumOnly ? 'Chromium' : ffOnly ? 'Firefox' : ''} manifest...`) |
| 61 | + console.log(`Bumping version in ${ |
| 62 | + config.chromiumOnly ? 'Chromium' : config.ffOnly ? 'Firefox' : ''} manifest...`) |
60 | 63 | const { oldVer, newVer } = bump.bumpDateVer({ filePath: manifestPath }) |
61 | 64 | bumpedManifests[`${platformManifestPath}/manifest.json`] = `${oldVer};${newVer}` |
62 | 65 | } |
|
69 | 72 |
|
70 | 73 |
|
71 | 74 | // ADD/COMMIT/PUSH bump(s) |
72 | | - if (!noCommit) { |
| 75 | + if (!config.noCommit) { |
73 | 76 | bump.log.working(`\nCommitting bump${pluralSuffix} to Git...\n`) |
74 | 77 |
|
75 | 78 | // Init commit msg |
|
83 | 86 | try { |
84 | 87 | execSync('git add ./**/manifest.json') |
85 | 88 | spawnSync('git', ['commit', '-n', '-m', commitMsg], { stdio: 'inherit', encoding: 'utf-8' }) |
86 | | - if (!noPush) { |
| 89 | + if (!config.noPush) { |
87 | 90 | bump.log.working('\nPulling latest changes from remote to sync local repository...\n') |
88 | 91 | execSync('git pull') |
89 | 92 | bump.log.working('\nPushing bump${pluralSuffix} to Git...\n') |
90 | 93 | execSync('git push') |
91 | 94 | } |
92 | 95 | bump.log.success(`Success! ${Object.keys(bumpedManifests).length} manifest${pluralSuffix} updated${ |
93 | | - !noCommit ? '/committed' : '' }${ !noPush ? '/pushed' : '' } to GitHub`) |
| 96 | + !config.noCommit ? '/committed' : '' }${ !config.noPush ? '/pushed' : '' } to GitHub`) |
94 | 97 | } catch (err) { bump.log.error('Git operation failed: ' + err.message) } |
95 | 98 | } |
96 | 99 |
|
|
0 commit comments