Skip to content

Commit

Permalink
fix(deps): update dependency dargs to v8 (#1028)
Browse files Browse the repository at this point in the history
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
  • Loading branch information
renovate[bot] committed Aug 6, 2023
1 parent c026e30 commit 1dbcc99
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 58 deletions.
105 changes: 53 additions & 52 deletions packages/git-raw-commits/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
'use strict'

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

const DELIMITER = '------------------------ >8 ------------------------'

function normalizeExecOpts (execOpts) {
execOpts = execOpts || {}
execOpts.cwd = execOpts.cwd || process.cwd()

return execOpts
}

Expand All @@ -18,13 +18,14 @@ function normalizeGitOpts (gitOpts) {
gitOpts.format = gitOpts.format || '%B'
gitOpts.from = gitOpts.from || ''
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']
Expand All @@ -41,60 +42,60 @@ function getGitArgs (gitOpts) {

function gitRawCommits (rawGitOpts, rawExecOpts) {
const readable = new Readable()
readable._read = function () {}
readable._read = () => {}

const gitOpts = normalizeGitOpts(rawGitOpts)
const execOpts = normalizeExecOpts(rawExecOpts)
const args = getGitArgs(gitOpts)

if (gitOpts.debug) {
gitOpts.debug('Your git-log command is:\ngit ' + args.join(' '))
}

let isError = false

const child = execFile('git', args, {
cwd: execOpts.cwd,
maxBuffer: Infinity
getGitArgs(gitOpts).then((args) => {
if (gitOpts.debug) {
gitOpts.debug('Your git-log command is:\ngit ' + args.join(' '))
}

const child = execFile('git', args, {
cwd: execOpts.cwd,
maxBuffer: Infinity
})

child.stdout
.pipe(split(DELIMITER + '\n'))
.pipe(
new Transform({
transform (chunk, enc, cb) {
isError = false
setImmediate(() => {
readable.push(chunk)
cb()
})
},
flush (cb) {
setImmediate(() => {
if (!isError) {
readable.push(null)
readable.emit('close')
}

cb()
})
}
})
)

child.stderr
.pipe(
new Transform({
objectMode: true,
highWaterMark: 16,
transform (chunk) {
isError = true
readable.emit('error', new Error(chunk))
readable.emit('close')
}
})
)
})

child.stdout
.pipe(split(DELIMITER + '\n'))
.pipe(
new Transform({
transform (chunk, enc, cb) {
isError = false
setImmediate(() => {
readable.push(chunk)
cb()
})
},
flush (cb) {
setImmediate(function () {
if (!isError) {
readable.push(null)
readable.emit('close')
}

cb()
})
}
})
)

child.stderr
.pipe(
new Transform({
objectMode: true,
highWaterMark: 16,
transform (chunk) {
isError = true
readable.emit('error', new Error(chunk))
readable.emit('close')
}
})
)

return readable
}

Expand Down
2 changes: 1 addition & 1 deletion packages/git-raw-commits/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"git-log"
],
"dependencies": {
"dargs": "^7.0.0",
"dargs": "^8.0.0",
"meow": "^12.0.1",
"split2": "^4.0.0"
},
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1dbcc99

Please sign in to comment.