Created
September 2, 2020 16:21
-
-
Save sr2ds/20666cbae5621cf2ede8e7bffec8ae0d to your computer and use it in GitHub Desktop.
NodeJs script to get all tags in json format from local git repository
This file contains 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
// import lib to execute shell | |
const shellExec = require('shell-exec') | |
// build shell command to get tags with subject and date | |
const gitCommand = ` \ | |
git tag -l \ | |
--format='{\n | |
"tag": "%(tag)", \n \ | |
"subject": "%(subject)", \n \ | |
"created": "%(creatordate)" \n \ | |
},'\ | |
` | |
shellExec(gitCommand).then(res => { | |
// return array with tag objects | |
let jsoned = JSON.parse(`[ ${res.stdout.slice(0, -2)} ]`) | |
// console.log(jsoned) | |
return jsoned | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment