Skip to content

Commit

Permalink
Update build script
Browse files Browse the repository at this point in the history
  • Loading branch information
berzniz committed Jan 15, 2020
1 parent e342272 commit a4fc0c7
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions utils/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,32 @@ const chromeWebStoreItemProperty = require('chrome-web-store-item-property')
const webpack = require('webpack')
const config = require('../webpack.config')
const chromeStoreId = 'nfhdjopbhlggibjlimhdbogflgmbiahc'

const bumpMinorVersion = (version) => {
const splitVersion = version.split('.')
splitVersion[2] = (1 + parseInt(splitVersion[2], 10))
return splitVersion.join('.')
}

console.log('📞 Getting version from Chrome Webstore...')
chromeWebStoreItemProperty(chromeStoreId).then(value => {
const getChromeVersion = async () => {
console.log('📞 Getting version from Chrome Webstore...')
const value = await chromeWebStoreItemProperty(chromeStoreId)

console.log('🔥 Chrome Webstore version:', value.version)
const newVersion = bumpMinorVersion(value.version)
return value.version
}

const getNewVersion = async () => {
if (process.env.NEW_VERSION) {
return process.env.NEW_VERSION
}

const currentChromeVersion = await getChromeVersion()
return bumpMinorVersion(currentChromeVersion)
}

const start = async () => {
const newVersion = await getNewVersion()
console.log('🚀 New version:', newVersion)
process.env.extension_version = newVersion
require('./prepare')
Expand All @@ -24,7 +40,8 @@ chromeWebStoreItemProperty(chromeStoreId).then(value => {
}
}
)
})
.catch(err => {
console.error('Failed getting version from Chrome Webstore', err)
})
}

start()
.then(console.log)
.catch(console.log)

0 comments on commit a4fc0c7

Please sign in to comment.