Skip to content

Commit a4fc0c7

Browse files
committed
Update build script
1 parent e342272 commit a4fc0c7

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

Diff for: utils/build.js

+24-7
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,32 @@ const chromeWebStoreItemProperty = require('chrome-web-store-item-property')
22
const webpack = require('webpack')
33
const config = require('../webpack.config')
44
const chromeStoreId = 'nfhdjopbhlggibjlimhdbogflgmbiahc'
5+
56
const bumpMinorVersion = (version) => {
67
const splitVersion = version.split('.')
78
splitVersion[2] = (1 + parseInt(splitVersion[2], 10))
89
return splitVersion.join('.')
910
}
1011

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+
1316
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()
1531
console.log('🚀 New version:', newVersion)
1632
process.env.extension_version = newVersion
1733
require('./prepare')
@@ -24,7 +40,8 @@ chromeWebStoreItemProperty(chromeStoreId).then(value => {
2440
}
2541
}
2642
)
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

Comments
 (0)