Socket
Socket
Sign inDemoInstall

git-raw-commits

Package Overview
Dependencies
3
Maintainers
3
Versions
35
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.0 to 4.0.0

cli.mjs

114

index.js

@@ -1,7 +0,5 @@

'use strict'
const dargs = require('dargs')
const execFile = require('child_process').execFile
const { Readable, Transform } = require('stream')
const { execFile } = require('child_process')
const split = require('split2')
const { Readable, Transform } = require('stream')

@@ -13,2 +11,3 @@ const DELIMITER = '------------------------ >8 ------------------------'

execOpts.cwd = execOpts.cwd || process.cwd()
return execOpts

@@ -22,18 +21,19 @@ }

gitOpts.to = gitOpts.to || 'HEAD'
return gitOpts
}
function getGitArgs (gitOpts) {
async function getGitArgs (gitOpts) {
const { default: dargs } = await import('dargs')
const gitFormat = `--format=${gitOpts.format || ''}%n${DELIMITER}`
const gitFromTo = [gitOpts.from, gitOpts.to].filter(Boolean).join('..')
const gitArgs = ['log', gitFormat, gitFromTo]
.concat(dargs(gitOpts, {
excludes: ['debug', 'from', 'to', 'format', 'path']
excludes: ['debug', 'from', 'to', 'format', 'path', 'ignore']
}))
// allow commits to focus on a single directory
// allow commits to focus on specific directories.
// this is useful for monorepos.
if (gitOpts.path) {
gitArgs.push('--', gitOpts.path)
gitArgs.push('--', ...Array.isArray(gitOpts.path) ? gitOpts.path : [gitOpts.path])
}

@@ -46,55 +46,65 @@

const readable = new Readable()
readable._read = function () {}
readable._read = () => {}
const gitOpts = normalizeGitOpts(rawGitOpts)
const execOpts = normalizeExecOpts(rawExecOpts)
const args = getGitArgs(gitOpts)
let isError = false
if (gitOpts.debug) {
gitOpts.debug('Your git-log command is:\ngit ' + args.join(' '))
}
getGitArgs(gitOpts).then((args) => {
if (gitOpts.debug) {
gitOpts.debug('Your git-log command is:\ngit ' + args.join(' '))
}
let isError = false
const ignoreRegex = typeof gitOpts.ignore === 'string'
? new RegExp(gitOpts.ignore)
: gitOpts.ignore
const shouldNotIgnore = ignoreRegex
? chunk => !ignoreRegex.test(chunk.toString())
: () => true
const child = execFile('git', args, {
cwd: execOpts.cwd,
maxBuffer: Infinity
})
const child = execFile('git', args, {
cwd: execOpts.cwd,
maxBuffer: Infinity
})
child.stdout
.pipe(split(DELIMITER + '\n'))
.pipe(
new Transform({
transform (chunk, enc, cb) {
readable.push(chunk)
isError = false
child.stdout
.pipe(split(DELIMITER + '\n'))
.pipe(
new Transform({
transform (chunk, enc, cb) {
isError = false
setImmediate(() => {
if (shouldNotIgnore(chunk)) {
readable.push(chunk)
}
cb()
})
},
flush (cb) {
setImmediate(() => {
if (!isError) {
readable.push(null)
readable.emit('close')
}
cb()
},
flush (cb) {
setImmediate(function () {
if (!isError) {
readable.push(null)
readable.emit('close')
}
cb()
})
}
})
)
cb()
})
}
})
)
child.stderr
.pipe(
new Transform({
objectMode: true,
highWaterMark: 16,
transform (chunk) {
isError = true
readable.emit('error', new Error(chunk))
readable.emit('close')
}
})
)
})
child.stderr
.pipe(
new Transform({
objectMode: true,
highWaterMark: 16,
transform (chunk) {
isError = true
readable.emit('error', new Error(chunk))
readable.emit('close')
}
})
)
return readable

@@ -101,0 +111,0 @@ }

{
"name": "git-raw-commits",
"version": "3.0.0",
"version": "4.0.0",
"description": "Get raw git commits out of your repository using git-log(1)",

@@ -20,7 +20,7 @@ "bugs": {

"engines": {
"node": ">=14"
"node": ">=16"
},
"files": [
"index.js",
"cli.js"
"cli.mjs"
],

@@ -37,12 +37,9 @@ "keywords": [

"dependencies": {
"dargs": "^7.0.0",
"meow": "^8.1.2",
"split2": "^3.2.2"
"dargs": "^8.0.0",
"meow": "^12.0.1",
"split2": "^4.0.0"
},
"bin": {
"git-raw-commits": "cli.js"
},
"scripts": {
"test-windows": "mocha --timeout 30000"
"git-raw-commits": "cli.mjs"
}
}

@@ -62,5 +62,5 @@ # [![NPM version][npm-image]][npm-url] [![Build Status: Linux][travis-image]][travis-url] [![Build Status: Windows][appveyor-image]][appveyor-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage Status][coverage-image]][coverage-url]

Type: `string`
Type: `string` or `array`
Filter commits to the path provided.
Filter commits to the path(s) provided.

@@ -67,0 +67,0 @@ ##### execOpts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc