1
1
mirror of https://github.com/leon-ai/leon.git synced 2024-11-24 04:31:31 +03:00
leon/scripts/release/update-version.js
2021-03-16 01:39:52 +08:00

31 lines
679 B
JavaScript

import { command } from 'execa'
import log from '@/helpers/log'
/**
* Update version number in files which need version number
*/
export default (version) => new Promise(async (resolve, reject) => {
log.info('Updating version...')
const promises = []
const files = [
'package.json',
'package-lock.json'
]
for (let i = 0; i < files.length; i += 1) {
promises.push(command(`json -I -f ${files[i]} -e 'this.version="${version}"'`, { shell: true }))
}
try {
await Promise.all(promises)
log.success(`Version updated to ${version}`)
resolve()
} catch (e) {
log.error(`Error while updating version: ${e.stderr}`)
reject(e)
}
})