Skip to content

Instantly share code, notes, and snippets.

@sr2ds
Created September 2, 2020 16:21
Show Gist options
  • Save sr2ds/20666cbae5621cf2ede8e7bffec8ae0d to your computer and use it in GitHub Desktop.
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
// 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