1
1
mirror of https://github.com/leon-ai/leon.git synced 2024-12-24 17:23:23 +03:00
leon/scripts/release/update-version.js

33 lines
768 B
JavaScript
Raw Normal View History

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