gitmoji-cli
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -53,3 +53,3 @@ #!/usr/bin/env node | ||
if (cli.flags.commit) { | ||
gitmojiCli.ask(); | ||
gitmojiCli.ask('client'); | ||
} | ||
@@ -60,1 +60,5 @@ | ||
} | ||
if (cli.flags.hook) { | ||
gitmojiCli.ask('hook'); | ||
} |
{ | ||
"name": "gitmoji-cli", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "A gitmoji client for using emojis on commit messages.", | ||
@@ -5,0 +5,0 @@ "engines": { |
@@ -19,3 +19,3 @@ 'use strict'; | ||
const path = `${process.env.PWD}/.git/hooks`; | ||
const fileContents = `#!/bin/sh\n# gitmoji as a commit hook\ngitmoji -c $1`; | ||
const fileContents = `#!/bin/sh\n# gitmoji as a commit hook\nexec < /dev/tty\ngitmoji --hook $1`; | ||
@@ -50,3 +50,3 @@ fs.writeFile(`${path}/prepare-commit-msg`, fileContents, {mode: 755}, err => { | ||
ask() { | ||
ask(mode) { | ||
if (this._isAGitRepo('.git')) { | ||
@@ -60,3 +60,11 @@ return this._gitmojiApiClient.request({ | ||
inquirer.prompt(questions).then(answers => { | ||
this._commit(answers); | ||
switch (mode) { | ||
case 'client': | ||
this._commit(answers); | ||
break; | ||
case 'hook': | ||
this._hook(answers); | ||
break; | ||
} | ||
}); | ||
@@ -66,6 +74,13 @@ }) | ||
} | ||
console.error(chalk.red('ERROR: This directory is not a git repository.')); | ||
} | ||
_hook(answers) { | ||
const commitTitle = `${answers.gitmoji} ${answers.title}`; | ||
const reference = (answers.reference) ? `#${answers.reference}` : ''; | ||
const commitBody = `${answers.message} ${reference}`; | ||
fs.writeFileSync(process.argv[3], `${commitTitle}\n${commitBody}`); | ||
} | ||
_commit(answers) { | ||
@@ -72,0 +87,0 @@ const commitTitle = `${answers.gitmoji} ${answers.title}`; |
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
77829
233