2017-09-09 22:30:36 +00:00
|
|
|
const fs = require('fs')
|
2017-09-09 22:56:03 +00:00
|
|
|
const semver = require('semver')
|
2017-09-09 22:30:36 +00:00
|
|
|
const child_process = require('child_process')
|
|
|
|
|
2017-09-09 22:56:03 +00:00
|
|
|
const devVersion = child_process.execSync('npm show tone@next version').toString()
|
|
|
|
const masterVersion = child_process.execSync('npm show tone version').toString()
|
|
|
|
|
|
|
|
//go with whichever is the latest version
|
|
|
|
let version = masterVersion
|
|
|
|
if (semver.gt(devVersion, masterVersion)){
|
|
|
|
version = devVersion
|
|
|
|
}
|
2017-09-09 22:30:36 +00:00
|
|
|
|
|
|
|
version = version.split('.')
|
|
|
|
//increment the patch
|
|
|
|
version[2] = parseInt(version[2]) + 1
|
|
|
|
//put it back in semver
|
|
|
|
version = version.join('.')
|
2017-09-09 22:56:03 +00:00
|
|
|
console.log(`incrementing to version ${version}`)
|
2017-09-09 22:30:36 +00:00
|
|
|
|
|
|
|
//write it to the package.json
|
2017-09-09 22:56:03 +00:00
|
|
|
const packageFile = '../package.json'
|
2017-09-09 22:30:36 +00:00
|
|
|
const package = JSON.parse(fs.readFileSync(packageFile, 'utf-8'))
|
|
|
|
package.version = version
|
|
|
|
fs.writeFileSync(packageFile, JSON.stringify(package, undefined, ' '))
|