Skip to content

Instantly share code, notes, and snippets.

@ifgeny87
Created November 21, 2020 05:45
Show Gist options
  • Select an option

  • Save ifgeny87/c0f5ab31112f3c73a512484d5741acc6 to your computer and use it in GitHub Desktop.

Select an option

Save ifgeny87/c0f5ab31112f3c73a512484d5741acc6 to your computer and use it in GitHub Desktop.
Increase package.json version after commit done
#!/usr/local/bin/node
// Increase package.json version after commit done
const fs = require('fs')
const path = require('path')
const { exec } = require('child_process')
const packagePath = path.resolve(__dirname, '..', '..', 'package.json')
const package = require(packagePath)
const v = package.version.split('.')
v.push(Number(v.pop()) + 1)
package.version = v.join('.')
fs.writeFileSync(packagePath, JSON.stringify(package, 1, ' '))
exec('git add package.json', (error, stdout, stderr) => {
if (error) {
console.error(error)
process.exit(1)
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment