gitmoji-cli
Advanced tools
Comparing version 1.5.3 to 1.5.4
{ | ||
"name": "gitmoji-cli", | ||
"version": "1.5.3", | ||
"version": "1.5.4", | ||
"description": "A gitmoji client for using emojis on commit messages.", | ||
@@ -45,3 +45,3 @@ "engines": { | ||
"chalk": "^1.1.3", | ||
"conf": "^0.12.0", | ||
"conf": "^1.1.1", | ||
"execa": "^0.6.0", | ||
@@ -48,0 +48,0 @@ "inquirer": "^3.0.1", |
@@ -22,2 +22,5 @@ 'use strict'; | ||
} | ||
if (config.get('issueFormat') === undefined) { | ||
config.set('issueFormat', 'github'); | ||
} | ||
} | ||
@@ -31,2 +34,8 @@ | ||
type: 'confirm' | ||
}, | ||
{ | ||
name: 'issueFormat', | ||
message: 'Choose Issue Format', | ||
type: 'list', | ||
choices: ['github', 'jira'] | ||
} | ||
@@ -37,2 +46,3 @@ ]; | ||
config.set('autoadd', answers.add); | ||
config.set('issueFormat', answers.issueFormat); | ||
}); | ||
@@ -51,3 +61,3 @@ } | ||
} | ||
console.log(`${chalk.yellow('gitmoji')} commit hook created succesfully.`); | ||
console.log(`${chalk.yellow('gitmoji')} commit hook created successfully.`); | ||
}); | ||
@@ -123,3 +133,4 @@ } | ||
const title = `${answers.gitmoji} ${answers.title}`; | ||
const reference = (answers.reference) ? `#${answers.reference}` : ''; | ||
const prefixReference = config.get('issueFormat') === 'github' ? '#' : ''; | ||
const reference = (answers.reference) ? `${prefixReference}${answers.reference}` : ''; | ||
const signed = this._isCommitSigned(answers.signed); | ||
@@ -176,3 +187,3 @@ const body = `${answers.message} ${reference}`; | ||
name: 'reference', | ||
message: 'Issue / PR reference #:', | ||
message: 'Issue / PR reference:', | ||
validate(value) { | ||
@@ -183,7 +194,18 @@ if (value === '') { | ||
if (value !== null) { | ||
const validReference = value.match(/(^[1-9][0-9]*)+$/); | ||
let validReference = ''; | ||
let errorReference = ''; | ||
switch (config.get('issueFormat')) { | ||
case 'jira': | ||
validReference = value.match(/^([A-Z][A-Z0-9]{1,9}-[0-9]+)$/g); | ||
errorReference = 'Enter the JIRA reference key, such as ABC-123'; | ||
break; | ||
default: | ||
validReference = value.match(/(^[1-9][0-9]*)+$/); | ||
errorReference = 'Enter the number of the reference without the #. Eg: 12'; | ||
} | ||
if (validReference) { | ||
return true; | ||
} | ||
return chalk.red('Enter the number of the reference without the #. Eg: 12'); | ||
return chalk.red(errorReference); | ||
} | ||
@@ -249,3 +271,3 @@ } | ||
}).then(res => { | ||
console.log(`${chalk.yellow('Gitmojis')} updated succesfully!`); | ||
console.log(`${chalk.yellow('Gitmojis')} updated successfully!`); | ||
return res.data.gitmojis; | ||
@@ -252,0 +274,0 @@ }) |
@@ -8,3 +8,6 @@ 'use strict'; | ||
const pkg = require('./../package.json'); | ||
const Conf = require('conf'); | ||
const config = new Conf(); | ||
const gitmojiApiClient = axios.create({ | ||
@@ -25,2 +28,10 @@ baseURL: 'https://raw.githubusercontent.com/carloscuesta/gitmoji/master', | ||
const promptsForJiraCommit = { | ||
gitmoji: ':zap:', | ||
title: 'Improving performance issues.', | ||
message: 'Refactored code.', | ||
reference: 'ABC-123', | ||
signed: true | ||
}; | ||
const gitmojiCli = new GitmojiCli(gitmojiApiClient); | ||
@@ -31,4 +42,5 @@ | ||
describe('commit', function() { | ||
describe('commit-with-github-format', function() { | ||
it('should return the formed commit based on the input prompts', function() { | ||
config.set('issueFormat', 'github'); | ||
gitmojiCli._commit(prompts).should.equal('git commit -S -m ":zap: Improving performance issues." -m "Refactored code. #5"'); | ||
@@ -38,2 +50,9 @@ }); | ||
describe('commit-with-jira-format', function() { | ||
it('should return the formed commit based on the input prompts', function() { | ||
config.set('issueFormat', 'jira'); | ||
gitmojiCli._commit(promptsForJiraCommit).should.equal('git commit -S -m ":zap: Improving performance issues." -m "Refactored code. ABC-123"'); | ||
}); | ||
}); | ||
describe('init', function() { | ||
@@ -40,0 +59,0 @@ it('path should be set to .git/hooks/prepare-commit-msg', function() { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
90630
388
+ Addedconf@1.4.0(transitive)
+ Addedfind-up@2.1.0(transitive)
+ Addedlocate-path@2.0.0(transitive)
+ Addedp-limit@1.3.0(transitive)
+ Addedp-locate@2.0.0(transitive)
+ Addedp-try@1.0.0(transitive)
+ Addedpkg-up@2.0.0(transitive)
- Removedconf@0.12.0(transitive)
- Removedmkdirp@0.5.6(transitive)
- Removedpkg-up@1.0.0(transitive)
Updatedconf@^1.1.1