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

git-authors-cli

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

git-authors-cli - npm Package Compare versions

Comparing version 1.0.1 to 1.0.3

61

bin/index.js

@@ -8,5 +8,9 @@ #!/usr/bin/env node

const chalk = require('chalk')
const { EOL } = require('os')
const path = require('path')
require('update-notifier')({ pkg: require('../package.json') }).notify()
const rootPkg = require('../package.json')
require('update-notifier')({ pkg: rootPkg }).notify()
const TTY = process.platform === 'win32' ? 'CON' : '/dev/tty'

@@ -18,5 +22,12 @@

const throwError = err => {
const message = chalk.red(err.message || err)
console.log(message)
const REGEX_EMAIL_VARIATIONS = /[.+]/g
const normalizeEmail = email =>
email.toLowerCase().replace(REGEX_EMAIL_VARIATIONS, '')
const isSameEmail = (email1, email2) =>
normalizeEmail(email1) === normalizeEmail(email2)
const processError = err => {
console.log(chalk.red(err.message || err))
process.exit(1)

@@ -26,3 +37,3 @@ }

const cli = require('meow')({
pkg: require('../package.json'),
pkg: rootPkg,
help: require('./help'),

@@ -61,15 +72,19 @@ flags: {

}
const { print, cwd, save } = cli.flags
;(async () => {
try {
if (!await existsFile('.git')) {
return throwError({ message: 'Ops, not git directory detected!' })
return processError({
message: 'Ops, not git directory detected!'
})
}
const { stdout, stderr } = await execa.shell(`git shortlog -sne < ${TTY}`, {
cwd
})
if (stderr) return throwError(stderr)
const { print, cwd, save } = cli.flags
const pkgPath = path.join(cwd, 'package.json')
const cmd = `git shortlog -sne < ${TTY}`
const { stdout, stderr } = await execa.shell(cmd, { cwd })
if (stderr) return processError(stderr)
const contributors = stdout
.split('\n')
.split(EOL)
.reduce((acc, line) => {

@@ -79,12 +94,22 @@ const [commits, author] = line.split('\t')

return acc.concat({
author,
commits: Number(commits.trim()),
author,
name,
email: email.replace('>', '')
email: email.replace('>', ''),
name
})
}, [])
.reduce((acc, contributor, indexContributor, contributors) => {
const index = acc.findIndex(({ email }) =>
isSameEmail(email, contributor.email)
)
const isPresent = index !== -1
if (!isPresent) return acc.concat(contributor)
acc[index].commits += contributor.commits
return acc
}, [])
.filter(({ author }) => !REGEX_BLACKLIST_KEYWORDS.test(author))
.sort((c1, c2) => c2.commits - c1.commits)
if (print) renderContributors(contributors)
const pkg = await loadPkg(`${cwd}/package.json`)
const pkg = await loadPkg(pkgPath)

@@ -94,3 +119,3 @@ if (pkg && save) {

const newPkg = { ...pkg, contributors: authors }
await jsonFuture.saveAsync(`${cwd}/package.json`, newPkg)
await jsonFuture.saveAsync(pkgPath, newPkg)
if (print) {

@@ -103,4 +128,4 @@ console.log(

} catch (err) {
throwError(err)
processError(err)
}
})()

@@ -0,1 +1,20 @@

<a name="1.0.3"></a>
## 1.0.3 (2018-06-22)
* Compare email user lowercase ([7977912](https://github.com/Kikobeats/git-authors-cli/commit/7977912))
* Consider email variations ([1c5c9a4](https://github.com/Kikobeats/git-authors-cli/commit/1c5c9a4))
* Merge contributos based on email ([430f7bc](https://github.com/Kikobeats/git-authors-cli/commit/430f7bc)), closes [#1](https://github.com/Kikobeats/git-authors-cli/issues/1)
* Release 1.0.2 ([479fdc2](https://github.com/Kikobeats/git-authors-cli/commit/479fdc2))
<a name="1.0.2"></a>
## 1.0.2 (2018-06-22)
* Compare email user lowercase ([7977912](https://github.com/Kikobeats/git-authors-cli/commit/7977912))
* Consider email variations ([1c5c9a4](https://github.com/Kikobeats/git-authors-cli/commit/1c5c9a4))
* Merge contributos based on email ([430f7bc](https://github.com/Kikobeats/git-authors-cli/commit/430f7bc)), closes [#1](https://github.com/Kikobeats/git-authors-cli/issues/1)
<a name="1.0.1"></a>

@@ -2,0 +21,0 @@ ## 1.0.1 (2018-06-20)

@@ -5,3 +5,3 @@ {

"homepage": "https://documentup.com/Kikobeats/git-authors-cli",
"version": "1.0.1",
"version": "1.0.3",
"bin": {

@@ -8,0 +8,0 @@ "git-authors-cli": "bin/index.js"

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