11const fs = require ( 'fs' )
22const path = require ( 'path' )
33const { execSync } = require ( 'child_process' )
4+ const readline = require ( 'readline' )
45
56const manifest_path = path . resolve ( __dirname , '../src/manifest.json' )
67const manifest = JSON . parse ( fs . readFileSync ( manifest_path , 'utf-8' ) )
@@ -15,17 +16,30 @@ const version_parts = manifest.version.split('.')
1516const last_segment = parseInt ( version_parts . pop ( ) , 10 ) || 0
1617
1718const next_segment = last_segment + 1
18- manifest . version = `${ date_prefix } .${ next_segment } `
19+ const next_version = `${ date_prefix } .${ next_segment } `
1920
20- fs . writeFileSync ( manifest_path , JSON . stringify ( manifest , null , 2 ) + '\n' )
21- console . log ( `Bump version of the browser extension to ${ manifest . version } ` )
21+ const rl = readline . createInterface ( {
22+ input : process . stdin ,
23+ output : process . stdout
24+ } )
2225
23- try {
24- execSync ( `git add "${ manifest_path } "` , { stdio : 'ignore' } )
25- execSync ( `git commit --no-verify -m "Bump version to ${ manifest . version } "` , {
26- stdio : 'ignore'
27- } )
28- console . log ( 'Successfully committed the version bump.' )
29- } catch ( error ) {
30- console . error ( 'Failed to commit version bump:' , error . message )
31- }
26+ rl . question ( `Bump version of the browser extension to ${ next_version } ? (y/N) ` , ( answer ) => {
27+ if ( answer . toLowerCase ( ) === 'y' ) {
28+ manifest . version = next_version
29+ fs . writeFileSync ( manifest_path , JSON . stringify ( manifest , null , 2 ) + '\n' )
30+ console . log ( `Bumped version of the browser extension to ${ manifest . version } ` )
31+
32+ try {
33+ execSync ( `git add "${ manifest_path } "` , { stdio : 'ignore' } )
34+ execSync ( `git commit --no-verify -m "Bump version to ${ manifest . version } "` , {
35+ stdio : 'ignore'
36+ } )
37+ console . log ( 'Successfully committed the version bump.' )
38+ } catch ( error ) {
39+ console . error ( 'Failed to commit version bump:' , error . message )
40+ }
41+ } else {
42+ console . log ( 'Version bump aborted.' )
43+ }
44+ rl . close ( )
45+ } )
0 commit comments