git-raw-commits 3.0.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/{cli.js → cli.mjs} +7 -6
- package/index.js +65 -55
- package/package.json +7 -10
package/README.md
CHANGED
package/{cli.js → cli.mjs}
RENAMED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const gitRawCommits = require('./')
|
|
2
|
+
import meow from 'meow'
|
|
3
|
+
import gitRawCommits from './index.js'
|
|
5
4
|
|
|
6
5
|
const cli = meow(`
|
|
7
6
|
Usage
|
|
8
7
|
git-raw-commits [<git-log(1)-options>]
|
|
9
8
|
|
|
10
9
|
Example
|
|
11
|
-
git-raw-commits --from HEAD~2 --to HEAD
|
|
12
|
-
|
|
10
|
+
git-raw-commits --from HEAD~2 --to HEAD^
|
|
11
|
+
`, {
|
|
12
|
+
importMeta: import.meta
|
|
13
|
+
})
|
|
13
14
|
|
|
14
15
|
gitRawCommits(cli.flags)
|
|
15
|
-
.on('error',
|
|
16
|
+
.on('error', (err) => {
|
|
16
17
|
process.stderr.write(err)
|
|
17
18
|
process.exit(1)
|
|
18
19
|
})
|
package/index.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
'use strict'
|
|
2
1
|
|
|
3
|
-
const dargs = require('dargs')
|
|
4
|
-
const execFile = require('child_process').execFile
|
|
5
|
-
const split = require('split2')
|
|
6
2
|
const { Readable, Transform } = require('stream')
|
|
3
|
+
const { execFile } = require('child_process')
|
|
4
|
+
const split = require('split2')
|
|
7
5
|
|
|
8
6
|
const DELIMITER = '------------------------ >8 ------------------------'
|
|
9
7
|
|
|
10
8
|
function normalizeExecOpts (execOpts) {
|
|
11
9
|
execOpts = execOpts || {}
|
|
12
10
|
execOpts.cwd = execOpts.cwd || process.cwd()
|
|
11
|
+
|
|
13
12
|
return execOpts
|
|
14
13
|
}
|
|
15
14
|
|
|
@@ -18,22 +17,23 @@ function normalizeGitOpts (gitOpts) {
|
|
|
18
17
|
gitOpts.format = gitOpts.format || '%B'
|
|
19
18
|
gitOpts.from = gitOpts.from || ''
|
|
20
19
|
gitOpts.to = gitOpts.to || 'HEAD'
|
|
20
|
+
|
|
21
21
|
return gitOpts
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
function getGitArgs (gitOpts) {
|
|
24
|
+
async function getGitArgs (gitOpts) {
|
|
25
|
+
const { default: dargs } = await import('dargs')
|
|
25
26
|
const gitFormat = `--format=${gitOpts.format || ''}%n${DELIMITER}`
|
|
26
27
|
const gitFromTo = [gitOpts.from, gitOpts.to].filter(Boolean).join('..')
|
|
27
|
-
|
|
28
28
|
const gitArgs = ['log', gitFormat, gitFromTo]
|
|
29
29
|
.concat(dargs(gitOpts, {
|
|
30
|
-
excludes: ['debug', 'from', 'to', 'format', 'path']
|
|
30
|
+
excludes: ['debug', 'from', 'to', 'format', 'path', 'ignore']
|
|
31
31
|
}))
|
|
32
32
|
|
|
33
|
-
// allow commits to focus on
|
|
33
|
+
// allow commits to focus on specific directories.
|
|
34
34
|
// this is useful for monorepos.
|
|
35
35
|
if (gitOpts.path) {
|
|
36
|
-
gitArgs.push('--', gitOpts.path)
|
|
36
|
+
gitArgs.push('--', ...Array.isArray(gitOpts.path) ? gitOpts.path : [gitOpts.path])
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
return gitArgs
|
|
@@ -41,59 +41,69 @@ function getGitArgs (gitOpts) {
|
|
|
41
41
|
|
|
42
42
|
function gitRawCommits (rawGitOpts, rawExecOpts) {
|
|
43
43
|
const readable = new Readable()
|
|
44
|
-
readable._read =
|
|
44
|
+
readable._read = () => {}
|
|
45
45
|
|
|
46
46
|
const gitOpts = normalizeGitOpts(rawGitOpts)
|
|
47
47
|
const execOpts = normalizeExecOpts(rawExecOpts)
|
|
48
|
-
const args = getGitArgs(gitOpts)
|
|
49
|
-
|
|
50
|
-
if (gitOpts.debug) {
|
|
51
|
-
gitOpts.debug('Your git-log command is:\ngit ' + args.join(' '))
|
|
52
|
-
}
|
|
53
|
-
|
|
54
48
|
let isError = false
|
|
55
49
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
getGitArgs(gitOpts).then((args) => {
|
|
51
|
+
if (gitOpts.debug) {
|
|
52
|
+
gitOpts.debug('Your git-log command is:\ngit ' + args.join(' '))
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const ignoreRegex = typeof gitOpts.ignore === 'string'
|
|
56
|
+
? new RegExp(gitOpts.ignore)
|
|
57
|
+
: gitOpts.ignore
|
|
58
|
+
const shouldNotIgnore = ignoreRegex
|
|
59
|
+
? chunk => !ignoreRegex.test(chunk.toString())
|
|
60
|
+
: () => true
|
|
61
|
+
|
|
62
|
+
const child = execFile('git', args, {
|
|
63
|
+
cwd: execOpts.cwd,
|
|
64
|
+
maxBuffer: Infinity
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
child.stdout
|
|
68
|
+
.pipe(split(DELIMITER + '\n'))
|
|
69
|
+
.pipe(
|
|
70
|
+
new Transform({
|
|
71
|
+
transform (chunk, enc, cb) {
|
|
72
|
+
isError = false
|
|
73
|
+
setImmediate(() => {
|
|
74
|
+
if (shouldNotIgnore(chunk)) {
|
|
75
|
+
readable.push(chunk)
|
|
76
|
+
}
|
|
77
|
+
cb()
|
|
78
|
+
})
|
|
79
|
+
},
|
|
80
|
+
flush (cb) {
|
|
81
|
+
setImmediate(() => {
|
|
82
|
+
if (!isError) {
|
|
83
|
+
readable.push(null)
|
|
84
|
+
readable.emit('close')
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
cb()
|
|
88
|
+
})
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
child.stderr
|
|
94
|
+
.pipe(
|
|
95
|
+
new Transform({
|
|
96
|
+
objectMode: true,
|
|
97
|
+
highWaterMark: 16,
|
|
98
|
+
transform (chunk) {
|
|
99
|
+
isError = true
|
|
100
|
+
readable.emit('error', new Error(chunk))
|
|
101
|
+
readable.emit('close')
|
|
102
|
+
}
|
|
103
|
+
})
|
|
104
|
+
)
|
|
59
105
|
})
|
|
60
106
|
|
|
61
|
-
child.stdout
|
|
62
|
-
.pipe(split(DELIMITER + '\n'))
|
|
63
|
-
.pipe(
|
|
64
|
-
new Transform({
|
|
65
|
-
transform (chunk, enc, cb) {
|
|
66
|
-
readable.push(chunk)
|
|
67
|
-
isError = false
|
|
68
|
-
|
|
69
|
-
cb()
|
|
70
|
-
},
|
|
71
|
-
flush (cb) {
|
|
72
|
-
setImmediate(function () {
|
|
73
|
-
if (!isError) {
|
|
74
|
-
readable.push(null)
|
|
75
|
-
readable.emit('close')
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
cb()
|
|
79
|
-
})
|
|
80
|
-
}
|
|
81
|
-
})
|
|
82
|
-
)
|
|
83
|
-
|
|
84
|
-
child.stderr
|
|
85
|
-
.pipe(
|
|
86
|
-
new Transform({
|
|
87
|
-
objectMode: true,
|
|
88
|
-
highWaterMark: 16,
|
|
89
|
-
transform (chunk) {
|
|
90
|
-
isError = true
|
|
91
|
-
readable.emit('error', new Error(chunk))
|
|
92
|
-
readable.emit('close')
|
|
93
|
-
}
|
|
94
|
-
})
|
|
95
|
-
)
|
|
96
|
-
|
|
97
107
|
return readable
|
|
98
108
|
}
|
|
99
109
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "git-raw-commits",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Get raw git commits out of your repository using git-log(1)",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/conventional-changelog/conventional-changelog/issues"
|
|
@@ -17,11 +17,11 @@
|
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"engines": {
|
|
20
|
-
"node": ">=
|
|
20
|
+
"node": ">=16"
|
|
21
21
|
},
|
|
22
22
|
"files": [
|
|
23
23
|
"index.js",
|
|
24
|
-
"cli.
|
|
24
|
+
"cli.mjs"
|
|
25
25
|
],
|
|
26
26
|
"keywords": [
|
|
27
27
|
"git-raw-commits",
|
|
@@ -33,14 +33,11 @@
|
|
|
33
33
|
"git-log"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"dargs": "^
|
|
37
|
-
"meow": "^
|
|
38
|
-
"split2": "^
|
|
36
|
+
"dargs": "^8.0.0",
|
|
37
|
+
"meow": "^12.0.1",
|
|
38
|
+
"split2": "^4.0.0"
|
|
39
39
|
},
|
|
40
40
|
"bin": {
|
|
41
|
-
"git-raw-commits": "cli.
|
|
42
|
-
},
|
|
43
|
-
"scripts": {
|
|
44
|
-
"test-windows": "mocha --timeout 30000"
|
|
41
|
+
"git-raw-commits": "cli.mjs"
|
|
45
42
|
}
|
|
46
43
|
}
|