Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fea2aa5
commit b91e2ba
Showing
5 changed files
with
211 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ node_modules | |
npm-debug.log | ||
tmp | ||
.*.swp | ||
.idea | ||
package-lock.json |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
'use strict'; | ||
|
||
var async = require('grunt').util.async; | ||
var grunt = require('grunt'); | ||
var ArgUtil = require('flopmang'); | ||
|
||
module.exports = function (task, exec, done) { | ||
var options = task.options({ | ||
}); | ||
var argUtil = new ArgUtil(task, [ | ||
{ | ||
option: 'all', | ||
defaultValue: false, | ||
useAsFlag: true, | ||
useValue: false, | ||
useDasherize: true | ||
}, | ||
{ | ||
option: 'tags', | ||
defaultValue: false, | ||
useAsFlag: true, | ||
useValue: false, | ||
useDasherize: true | ||
}, | ||
{ | ||
option: 'contains', | ||
defaultValue: false, | ||
useAsFlag: true, | ||
useValue: false, | ||
useDasherize: true | ||
}, | ||
{ | ||
option: 'abbrev', | ||
defaultValue: 7, | ||
useAsFlag: true, | ||
useValue: false, | ||
useDasherize: true, | ||
customFlagFn: function (arg) { | ||
if (arg.value !== undefined) { | ||
return (arg.useDasherize ? '--' : '') + arg.option + '=' + arg.value; | ||
} | ||
return null; | ||
} | ||
}, | ||
{ | ||
option: 'candidates', | ||
defaultValue: 10, | ||
useAsFlag: true, | ||
useValue: false, | ||
useDasherize: true, | ||
customFlagFn: function (arg) { | ||
if (arg.value !== undefined) { | ||
return (arg.useDasherize ? '--' : '') + arg.option + '=' + arg.value; | ||
} | ||
return null; | ||
} | ||
}, | ||
{ | ||
option: 'commit-ish', | ||
defaultValue: 'HEAD', | ||
useAsFlag: false, | ||
useValue: true, | ||
required: false | ||
} | ||
]); | ||
|
||
function handleResult(err, result) { | ||
if (err) { | ||
grunt.fail.fatal('Error running git describe'); | ||
return; | ||
} | ||
|
||
if (typeof options.callback === 'function') { | ||
options.callback(result.stdout); | ||
} | ||
done(); | ||
} | ||
|
||
|
||
var args = ['describe'].concat(argUtil.getArgFlags()); | ||
args.push(handleResult); | ||
exec.apply(null, args); | ||
}; | ||
|
||
module.exports.description = 'Give an object a human readable name based on an available ref.'; | ||
|
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
'use strict'; | ||
|
||
var command = require('../lib/commands').describe; | ||
var Test = require('./_common'); | ||
|
||
describe('describe', function () { | ||
it('describe tag', function (done) { | ||
var options = { | ||
tags: true | ||
}; | ||
|
||
new Test(command, options) | ||
.expect(['describe', '--tags', '--abbrev=7', '--candidates=10', 'HEAD']) | ||
.run(done); | ||
}); | ||
|
||
it('describe all', function (done) { | ||
var options = { | ||
all: true | ||
}; | ||
|
||
new Test(command, options) | ||
.expect(['describe', '--all', '--abbrev=7', '--candidates=10', 'HEAD']) | ||
.run(done); | ||
}); | ||
|
||
it('describe abbrev', function (done) { | ||
var options = { | ||
abbrev: 0 | ||
}; | ||
|
||
new Test(command, options) | ||
.expect(['describe', '--abbrev=0', '--candidates=10', 'HEAD']) | ||
.run(done); | ||
}); | ||
|
||
it('describe candidates', function (done) { | ||
var options = { | ||
candidates: 5 | ||
}; | ||
|
||
new Test(command, options) | ||
.expect(['describe', '--abbrev=7', '--candidates=5', 'HEAD']) | ||
.run(done); | ||
}); | ||
|
||
it('describe contains', function (done) { | ||
var options = { | ||
contains: 5 | ||
}; | ||
|
||
new Test(command, options) | ||
.expect(['describe', '--contains', '--abbrev=7', '--candidates=10', 'HEAD']) | ||
.run(done); | ||
}); | ||
}); |