@@ -2,16 +2,32 @@ const chromeWebStoreItemProperty = require('chrome-web-store-item-property')
2
2
const webpack = require ( 'webpack' )
3
3
const config = require ( '../webpack.config' )
4
4
const chromeStoreId = 'nfhdjopbhlggibjlimhdbogflgmbiahc'
5
+
5
6
const bumpMinorVersion = ( version ) => {
6
7
const splitVersion = version . split ( '.' )
7
8
splitVersion [ 2 ] = ( 1 + parseInt ( splitVersion [ 2 ] , 10 ) )
8
9
return splitVersion . join ( '.' )
9
10
}
10
11
11
- console . log ( '📞 Getting version from Chrome Webstore...' )
12
- chromeWebStoreItemProperty ( chromeStoreId ) . then ( value => {
12
+ const getChromeVersion = async ( ) => {
13
+ console . log ( '📞 Getting version from Chrome Webstore...' )
14
+ const value = await chromeWebStoreItemProperty ( chromeStoreId )
15
+
13
16
console . log ( '🔥 Chrome Webstore version:' , value . version )
14
- const newVersion = bumpMinorVersion ( value . version )
17
+ return value . version
18
+ }
19
+
20
+ const getNewVersion = async ( ) => {
21
+ if ( process . env . NEW_VERSION ) {
22
+ return process . env . NEW_VERSION
23
+ }
24
+
25
+ const currentChromeVersion = await getChromeVersion ( )
26
+ return bumpMinorVersion ( currentChromeVersion )
27
+ }
28
+
29
+ const start = async ( ) => {
30
+ const newVersion = await getNewVersion ( )
15
31
console . log ( '🚀 New version:' , newVersion )
16
32
process . env . extension_version = newVersion
17
33
require ( './prepare' )
@@ -24,7 +40,8 @@ chromeWebStoreItemProperty(chromeStoreId).then(value => {
24
40
}
25
41
}
26
42
)
27
- } )
28
- . catch ( err => {
29
- console . error ( 'Failed getting version from Chrome Webstore' , err )
30
- } )
43
+ }
44
+
45
+ start ( )
46
+ . then ( console . log )
47
+ . catch ( console . log )
0 commit comments