Get the current Git branch name and pass it to another task's config
This plugin requires Grunt ~0.4.5
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-get-branchname --save-dev
Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:
grunt.loadNpmTasks('grunt-get-branchname');
In your project's Gruntfile, add a section named get_branchname
to the data object passed into grunt.initConfig()
.
grunt.initConfig({
get_branchname: {
options: {
// Task-specific options go here.
},
your_target: {
// Target-specific options go here.
},
},
});
Type: String
Default value: null
A string value that is used to specify the Grunt configuration object to inject the current Git branch name into
Type: Boolean
Default value: true
A Boolean to specify whether just the name of the branch is specified, e.g. master
, or whether the full symbolic-ref, e.g. refs/heads/master
is injected
Type: Boolean
Default value: false
A Boolean to specify whether any errors being returned by the command are suppressed
grunt.initConfig({
get_branchname: {
options: {
target: 'sometask.dev.branchname' // property will be created if it does not exist
},
},
});
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.
0.1.0 Initial release