2021-03-04 17:49:52 +03:00
|
|
|
import { command } from 'execa'
|
2019-02-10 15:26:50 +03:00
|
|
|
|
|
|
|
import log from '@/helpers/log'
|
|
|
|
|
|
|
|
/**
|
2019-03-02 07:54:25 +03:00
|
|
|
* Update version number in files which need version number
|
2019-02-10 15:26:50 +03:00
|
|
|
*/
|
2021-03-15 20:39:52 +03:00
|
|
|
export default (version) => new Promise(async (resolve, reject) => {
|
2019-02-10 15:26:50 +03:00
|
|
|
log.info('Updating version...')
|
|
|
|
|
|
|
|
const promises = []
|
|
|
|
const files = [
|
|
|
|
'package.json',
|
|
|
|
'package-lock.json'
|
|
|
|
]
|
|
|
|
|
|
|
|
for (let i = 0; i < files.length; i += 1) {
|
2021-03-04 17:49:52 +03:00
|
|
|
promises.push(command(`json -I -f ${files[i]} -e 'this.version="${version}"'`, { shell: true }))
|
2019-02-10 15:26:50 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
await Promise.all(promises)
|
|
|
|
|
|
|
|
log.success(`Version updated to ${version}`)
|
|
|
|
resolve()
|
|
|
|
} catch (e) {
|
|
|
|
log.error(`Error while updating version: ${e.stderr}`)
|
|
|
|
reject(e)
|
|
|
|
}
|
|
|
|
})
|