gitmoji-cli
Advanced tools
Comparing version 1.3.1 to 1.4.0
@@ -17,2 +17,3 @@ #!/usr/bin/env node | ||
--init, -i Initialize gitmoji as a commit hook | ||
--config, -g Setup gitmoji-cli preferences. | ||
--commit, -c Interactively commit using the prompts | ||
@@ -34,3 +35,4 @@ --list, -l List all the available gitmojis | ||
v: 'version', | ||
u: 'update' | ||
u: 'update', | ||
g: 'config' | ||
} | ||
@@ -50,2 +52,3 @@ }); | ||
list: () => gitmojiCli.list(), | ||
config: () => gitmojiCli.config(), | ||
search: () => cli.input.map(element => gitmojiCli.search(element)), | ||
@@ -52,0 +55,0 @@ init: () => gitmojiCli.init(), |
{ | ||
"name": "gitmoji-cli", | ||
"version": "1.3.1", | ||
"version": "1.4.0", | ||
"description": "A gitmoji client for using emojis on commit messages.", | ||
@@ -45,2 +45,3 @@ "engines": { | ||
"chalk": "^1.1.3", | ||
"conf": "^0.12.0", | ||
"execa": "^0.6.0", | ||
@@ -50,3 +51,3 @@ "inquirer": "^3.0.1", | ||
"path-exists": "^3.0.0", | ||
"update-notifier": "^1.0.2" | ||
"update-notifier": "^2.0.0" | ||
}, | ||
@@ -53,0 +54,0 @@ "devDependencies": { |
@@ -37,2 +37,3 @@ # gitmoji-cli | ||
--init, -i Initialize gitmoji as a commit hook | ||
--config, -g Setup gitmoji-cli preferences | ||
--commit, -c Interactively commit using the prompts | ||
@@ -97,1 +98,7 @@ --list, -l List all the available gitmojis | ||
``` | ||
### Config | ||
Run `gitmoji -g` to setup some gitmoji-cli preferences, such as the auto `git add .` feature. | ||
![gitmoji config](https://cloud.githubusercontent.com/assets/7629661/23577826/82e8745e-00c9-11e7-9d7e-623a0a51bff9.png) |
@@ -9,3 +9,6 @@ 'use strict'; | ||
const pathExists = require('path-exists'); | ||
const Conf = require('conf'); | ||
const config = new Conf(); | ||
class GitmojiCli { | ||
@@ -18,2 +21,16 @@ | ||
config() { | ||
const questions = [ | ||
{ | ||
name: 'add', | ||
message: 'Enable automatic "git add ."', | ||
type: 'confirm' | ||
} | ||
]; | ||
inquirer.prompt(questions).then(answers => { | ||
config.set('autoadd', answers.add); | ||
}); | ||
} | ||
init() { | ||
@@ -27,3 +44,3 @@ const hookFile = 'prepare-commit-msg'; | ||
if (err) { | ||
console.error(chalk.red(`ERROR: ${err}`)); | ||
this._errorMessage(err); | ||
} | ||
@@ -47,3 +64,3 @@ console.log(`${chalk.yellow('gitmoji')} commit hook created succesfully.`); | ||
.then(gitmojis => this._parseGitmojis(gitmojis)) | ||
.catch(err => console.error(chalk.red(`ERROR: gitmoji list not found - ${err.code}`))); | ||
.catch(err => this._errorMessage(`gitmoji list not found - ${err.code}`)); | ||
} | ||
@@ -55,3 +72,3 @@ | ||
.then(gitmojisFiltered => this._parseGitmojis(gitmojisFiltered)) | ||
.catch(err => console.error(chalk.red(`ERROR: ${err.code}`))); | ||
.catch(err => this._errorMessage(err.code)); | ||
} | ||
@@ -75,9 +92,9 @@ | ||
default: | ||
console.error(chalk.red(`ERROR: unexpected mode [${mode}]`)); | ||
this._errorMessage(`Unexpected mode [${mode}]`); | ||
} | ||
}); | ||
}) | ||
.catch(err => console.error(chalk.red(`ERROR: ${err.code}`))); | ||
.catch(err => this._errorMessage(err.code)); | ||
} | ||
console.error(chalk.red('ERROR: This directory is not a git repository.')); | ||
this._errorMessage('This directory is not a git repository.'); | ||
} | ||
@@ -90,26 +107,33 @@ | ||
_errorMessage(message) { | ||
console.error(chalk.red(`ERROR: ${message}`)); | ||
} | ||
_hook(answers) { | ||
const commitTitle = `${answers.gitmoji} ${answers.title}`; | ||
const title = `${answers.gitmoji} ${answers.title}`; | ||
const reference = (answers.reference) ? `#${answers.reference}` : ''; | ||
const commitBody = `${answers.message} ${reference}`; | ||
const body = `${answers.message} ${reference}`; | ||
fs.writeFileSync(process.argv[3], `${commitTitle}\n${commitBody}`); | ||
fs.writeFileSync(process.argv[3], `${title}\n${body}`); | ||
} | ||
_commit(answers) { | ||
const commitTitle = `${answers.gitmoji} ${answers.title}`; | ||
const title = `${answers.gitmoji} ${answers.title}`; | ||
const reference = (answers.reference) ? `#${answers.reference}` : ''; | ||
const signed = this._isCommitSigned(answers.signed); | ||
const commitBody = `${answers.message} ${reference}`; | ||
const body = `${answers.message} ${reference}`; | ||
const commit = `git commit ${signed} -m "${title}" -m "${body}"`; | ||
if (this._isAGitRepo('.git')) { | ||
execa.stdout('git', ['add', '.']) | ||
.then(res => console.log(chalk.blue(res))) | ||
.catch(err => console.error(chalk.red(`ERROR: ${err.stderr}`))); | ||
execa.shell(`git commit ${signed} -m "${commitTitle}" -m "${commitBody}"`) | ||
if (config.get('autoadd')) { | ||
execa.stdout('git', ['add', '.']) | ||
.then(res => console.log(chalk.blue(res))) | ||
.catch(err => this._errorMessage(err.stderr)); | ||
} | ||
execa.shell(commit) | ||
.then(res => console.log(chalk.blue(res.stdout))) | ||
.catch(err => console.error(chalk.red(`ERROR: ${err.stderr}`))); | ||
.catch(err => this._errorMessage(err.stderr)); | ||
} | ||
return `git commit ${signed} -m "${commitTitle}" -m "${commitBody}"`; | ||
return commit; | ||
} | ||
@@ -220,3 +244,3 @@ | ||
}) | ||
.catch(err => console.error(chalk.red(`ERROR: Network connection not found - ${err.code}`))); | ||
.catch(err => this._errorMessage(`Network connection not found - ${err.code}`)); | ||
} | ||
@@ -223,0 +247,0 @@ |
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
89946
343
103
8
+ Addedconf@^0.12.0
+ Addedansi-align@2.0.0(transitive)
+ Addedboxen@1.3.0(transitive)
+ Addedcamelcase@4.1.0(transitive)
+ Addedci-info@1.6.0(transitive)
+ Addedconf@0.12.0(transitive)
+ Addedconfigstore@3.1.5(transitive)
+ Addedcrypto-random-string@1.0.0(transitive)
+ Addeddot-prop@4.2.1(transitive)
+ Addedduplexer3@0.1.5(transitive)
+ Addedenv-paths@1.0.0(transitive)
+ Addedexeca@0.7.0(transitive)
+ Addedglobal-dirs@0.1.1(transitive)
+ Addedgot@6.7.1(transitive)
+ Addedimport-lazy@2.1.0(transitive)
+ Addedis-ci@1.2.1(transitive)
+ Addedis-installed-globally@0.1.0(transitive)
+ Addedis-path-inside@1.0.1(transitive)
+ Addedlatest-version@3.1.0(transitive)
+ Addedmake-dir@1.3.0(transitive)
+ Addedpackage-json@4.0.1(transitive)
+ Addedpath-is-inside@1.0.2(transitive)
+ Addedpify@3.0.0(transitive)
+ Addedpkg-up@1.0.0(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedterm-size@1.2.0(transitive)
+ Addedtimed-out@4.0.1(transitive)
+ Addedunique-string@1.0.0(transitive)
+ Addedunzip-response@2.0.1(transitive)
+ Addedupdate-notifier@2.5.0(transitive)
+ Addedwidest-line@2.0.1(transitive)
+ Addedwrite-file-atomic@2.4.3(transitive)
+ Addedxdg-basedir@3.0.0(transitive)
- Removedansi-align@1.1.0(transitive)
- Removedboxen@0.6.0(transitive)
- Removedcode-point-at@1.1.0(transitive)
- Removedconfigstore@2.1.0(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removeddot-prop@3.0.0(transitive)
- Removedduplexer2@0.1.4(transitive)
- Removedfilled-array@1.1.0(transitive)
- Removedgot@5.7.1(transitive)
- Removedinherits@2.0.4(transitive)
- Removedis-fullwidth-code-point@1.0.0(transitive)
- Removedisarray@1.0.0(transitive)
- Removedlatest-version@2.0.0(transitive)
- Removedlazy-req@1.1.0(transitive)
- Removednode-status-codes@1.0.0(transitive)
- Removednumber-is-nan@1.0.1(transitive)
- Removedos-homedir@1.0.2(transitive)
- Removedosenv@0.1.5(transitive)
- Removedpackage-json@2.4.0(transitive)
- Removedprocess-nextick-args@2.0.1(transitive)
- Removedread-all-stream@3.1.0(transitive)
- Removedreadable-stream@2.3.8(transitive)
- Removedsafe-buffer@5.1.2(transitive)
- Removedslide@1.1.6(transitive)
- Removedstring-width@1.0.2(transitive)
- Removedstring_decoder@1.1.1(transitive)
- Removedtimed-out@3.1.3(transitive)
- Removedunzip-response@1.0.2(transitive)
- Removedupdate-notifier@1.0.3(transitive)
- Removedutil-deprecate@1.0.2(transitive)
- Removeduuid@2.0.3(transitive)
- Removedwidest-line@1.0.0(transitive)
- Removedwrite-file-atomic@1.3.4(transitive)
- Removedxdg-basedir@2.0.0(transitive)
Updatedupdate-notifier@^2.0.0