0.0.2 • Published 8 years ago
babel-plugin-git-log-1 v0.0.2
babel-plugin-git-log-1
Babel plugin for inlining values from the last git commit.
Handy for embedding the relevant data from git into deployed web apps.
If you add
let git = require('babel-plugin-git-log-1')the plugin transforms the line to:
let git = {
ref: 'master',
dirty: false,
log: {
hash: '0603a72934b829f7490447b8d241bb9278e9c05d',
commiter: {
name: 'Alexander Gromnitsky',
email: 'alexander.gromnitsky@gmail.com',
date: '2018-03-31T14:21:12+03:00'
},
subject: 'init',
body: 'just a test'
}
};Setup
$ npm i babel-plugin-git-log-1Use it via the cli:
babel --plugins babel-plugin-git-log-1 foo.jsBy default, the plugin does its transformations only in the scope of modules, so this won't work:
function hello() {
let git = require('babel-plugin-git-log-1)
}To do the transformations everywhere, pass inner_scope option to the
plugin via .babelrc:
{
"plugins": [
["babel-plugin-git-log-1", {
"inner_scope": true
}]
]
}By default, the plugin operates on HEAD. To use another commit
object, use ref option.
Bugs
- Tested only w/ babel-cli 6.26.0 on Fedora 27.
- The plugin invokes
gitto grab the data, which is lame. The Right Way is to use nodegit (that uses libgit2), but I've seen people who scream when they see a native addon dependency, besides that a merenpm i nodegityields 89MBnode_modulesdir.
License
MIT.
0.0.2
8 years ago
0.0.1-security
8 years ago