Created
November 21, 2020 05:45
-
-
Save ifgeny87/c0f5ab31112f3c73a512484d5741acc6 to your computer and use it in GitHub Desktop.
Increase package.json version after commit done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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