Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gitmoji-cli

Package Overview
Dependencies
Maintainers
1
Versions
119
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gitmoji-cli - npm Package Compare versions

Comparing version 1.3.1 to 1.4.0

5

cli.js

@@ -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)

60

src/gitmoji.js

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc