git-raw-commits 2.0.11 → 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 CHANGED
@@ -1,4 +1,4 @@
1
- # [![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][coveralls-image]][coveralls-url]
1
+ # [![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]
2
2
 
3
3
  > Get raw git commits out of your repository using git-log(1)
4
4
 
@@ -59,9 +59,9 @@ A function to get debug information.
59
59
 
60
60
  ##### gitOpts.path
61
61
 
62
- Type: `string`
62
+ Type: `string` or `array`
63
63
 
64
- Filter commits to the path provided.
64
+ Filter commits to the path(s) provided.
65
65
 
66
66
  ##### execOpts
67
67
 
@@ -97,5 +97,5 @@ MIT © [Steve Mao](https://github.com/stevemao)
97
97
  [appveyor-url]: https://ci.appveyor.com/project/stevemao/git-raw-commits/branch/master
98
98
  [daviddm-image]: https://david-dm.org/conventional-changelog/git-raw-commits.svg?theme=shields.io
99
99
  [daviddm-url]: https://david-dm.org/conventional-changelog/git-raw-commits
100
- [coveralls-image]: https://coveralls.io/repos/conventional-changelog/git-raw-commits/badge.svg
101
- [coveralls-url]: https://coveralls.io/r/conventional-changelog/git-raw-commits
100
+ [coverage-image]: https://coveralls.io/repos/github/conventional-changelog/conventional-changelog/badge.svg?branch=master
101
+ [coverage-url]: https://coveralls.io/github/conventional-changelog/conventional-changelog?branch=master
@@ -1,18 +1,19 @@
1
1
  #!/usr/bin/env node
2
- 'use strict'
3
- const meow = require('meow')
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', function (err) {
16
+ .on('error', (err) => {
16
17
  process.stderr.write(err)
17
18
  process.exit(1)
18
19
  })
package/index.js CHANGED
@@ -1,17 +1,14 @@
1
- 'use strict'
2
1
 
3
- const dargs = require('dargs')
4
- const execFile = require('child_process').execFile
2
+ const { Readable, Transform } = require('stream')
3
+ const { execFile } = require('child_process')
5
4
  const split = require('split2')
6
- const stream = require('stream')
7
- const template = require('lodash/template')
8
- const through = require('through2')
9
5
 
10
6
  const DELIMITER = '------------------------ >8 ------------------------'
11
7
 
12
8
  function normalizeExecOpts (execOpts) {
13
9
  execOpts = execOpts || {}
14
10
  execOpts.cwd = execOpts.cwd || process.cwd()
11
+
15
12
  return execOpts
16
13
  }
17
14
 
@@ -20,71 +17,93 @@ function normalizeGitOpts (gitOpts) {
20
17
  gitOpts.format = gitOpts.format || '%B'
21
18
  gitOpts.from = gitOpts.from || ''
22
19
  gitOpts.to = gitOpts.to || 'HEAD'
20
+
23
21
  return gitOpts
24
22
  }
25
23
 
26
- function getGitArgs (gitOpts) {
27
- const gitFormat = template('--format=<%= format %>%n' + DELIMITER)(gitOpts)
24
+ async function getGitArgs (gitOpts) {
25
+ const { default: dargs } = await import('dargs')
26
+ const gitFormat = `--format=${gitOpts.format || ''}%n${DELIMITER}`
28
27
  const gitFromTo = [gitOpts.from, gitOpts.to].filter(Boolean).join('..')
29
-
30
28
  const gitArgs = ['log', gitFormat, gitFromTo]
31
29
  .concat(dargs(gitOpts, {
32
- excludes: ['debug', 'from', 'to', 'format', 'path']
30
+ excludes: ['debug', 'from', 'to', 'format', 'path', 'ignore']
33
31
  }))
34
32
 
35
- // allow commits to focus on a single directory
33
+ // allow commits to focus on specific directories.
36
34
  // this is useful for monorepos.
37
35
  if (gitOpts.path) {
38
- gitArgs.push('--', gitOpts.path)
36
+ gitArgs.push('--', ...Array.isArray(gitOpts.path) ? gitOpts.path : [gitOpts.path])
39
37
  }
40
38
 
41
39
  return gitArgs
42
40
  }
43
41
 
44
42
  function gitRawCommits (rawGitOpts, rawExecOpts) {
45
- const readable = new stream.Readable()
46
- readable._read = function () {}
43
+ const readable = new Readable()
44
+ readable._read = () => {}
47
45
 
48
46
  const gitOpts = normalizeGitOpts(rawGitOpts)
49
47
  const execOpts = normalizeExecOpts(rawExecOpts)
50
- const args = getGitArgs(gitOpts)
51
-
52
- if (gitOpts.debug) {
53
- gitOpts.debug('Your git-log command is:\ngit ' + args.join(' '))
54
- }
55
-
56
48
  let isError = false
57
49
 
58
- const child = execFile('git', args, {
59
- cwd: execOpts.cwd,
60
- maxBuffer: Infinity
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
+ )
61
105
  })
62
106
 
63
- child.stdout
64
- .pipe(split(DELIMITER + '\n'))
65
- .pipe(through(function (chunk, enc, cb) {
66
- readable.push(chunk)
67
- isError = false
68
-
69
- cb()
70
- }, function (cb) {
71
- setImmediate(function () {
72
- if (!isError) {
73
- readable.push(null)
74
- readable.emit('close')
75
- }
76
-
77
- cb()
78
- })
79
- }))
80
-
81
- child.stderr
82
- .pipe(through.obj(function (chunk) {
83
- isError = true
84
- readable.emit('error', new Error(chunk))
85
- readable.emit('close')
86
- }))
87
-
88
107
  return readable
89
108
  }
90
109
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "git-raw-commits",
3
- "version": "2.0.11",
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": ">=10"
20
+ "node": ">=16"
21
21
  },
22
22
  "files": [
23
23
  "index.js",
24
- "cli.js"
24
+ "cli.mjs"
25
25
  ],
26
26
  "keywords": [
27
27
  "git-raw-commits",
@@ -33,16 +33,11 @@
33
33
  "git-log"
34
34
  ],
35
35
  "dependencies": {
36
- "dargs": "^7.0.0",
37
- "lodash": "^4.17.15",
38
- "meow": "^8.0.0",
39
- "split2": "^3.0.0",
40
- "through2": "^4.0.0"
41
- },
42
- "scripts": {
43
- "test-windows": "mocha --timeout 30000"
36
+ "dargs": "^8.0.0",
37
+ "meow": "^12.0.1",
38
+ "split2": "^4.0.0"
44
39
  },
45
40
  "bin": {
46
- "git-raw-commits": "cli.js"
41
+ "git-raw-commits": "cli.mjs"
47
42
  }
48
- }
43
+ }
package/CHANGELOG.md DELETED
@@ -1,182 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- ### [2.0.11](https://github.com/conventional-changelog/conventional-changelog/compare/git-raw-commits-v2.0.10...git-raw-commits-v2.0.11) (2021-12-29)
7
-
8
-
9
- ### Bug Fixes
10
-
11
- * allow raw commits to be filtered by path and date range ([#893](https://github.com/conventional-changelog/conventional-changelog/issues/893)) ([b2245a7](https://github.com/conventional-changelog/conventional-changelog/commit/b2245a766c70d280380abbbe85c4894eee04fdd0))
12
-
13
- ### [2.0.10](https://www.github.com/conventional-changelog/conventional-changelog/compare/v2.0.9...v2.0.10) (2021-01-27)
14
-
15
-
16
- ### Bug Fixes
17
-
18
- * align lodash dependency across packages ([#737](https://www.github.com/conventional-changelog/conventional-changelog/issues/737)) ([d9feeb6](https://www.github.com/conventional-changelog/conventional-changelog/commit/d9feeb605de28c00ef55b5c8e229efd1289dd6e8))
19
- * revert normalize git show signature option to false ([c4d9042](https://www.github.com/conventional-changelog/conventional-changelog/commit/c4d9042ae83aa2c823dca181dd72e5a8b3163c1e))
20
-
21
- ### [2.0.9](https://www.github.com/conventional-changelog/conventional-changelog/compare/git-raw-commits@2.0.8...v2.0.9) (2020-12-29)
22
-
23
-
24
- ### Bug Fixes
25
-
26
- * normalize git show signature option to false ([#671](https://www.github.com/conventional-changelog/conventional-changelog/issues/671)) ([a0b348c](https://www.github.com/conventional-changelog/conventional-changelog/commit/a0b348c7a74ba49bb07053ed1d25c2053a7c3b1a)), closes [conventional-changelog/commitlint#2118](https://www.github.com/conventional-changelog/commitlint/issues/2118)
27
-
28
- ## [2.0.8](https://github.com/conventional-changelog/conventional-changelog/compare/git-raw-commits@2.0.7...git-raw-commits@2.0.8) (2020-11-05)
29
-
30
-
31
- ### Bug Fixes
32
-
33
- * **deps:** update dependency through2 to v4 ([#657](https://github.com/conventional-changelog/conventional-changelog/issues/657)) ([7ae618c](https://github.com/conventional-changelog/conventional-changelog/commit/7ae618c81491841e5b1d796d3933aac0c54bc312))
34
-
35
-
36
-
37
-
38
-
39
- ## [2.0.7](https://github.com/conventional-changelog/conventional-changelog/compare/git-raw-commits@2.0.3...git-raw-commits@2.0.7) (2020-05-08)
40
-
41
-
42
- ### Bug Fixes
43
-
44
- * **deps:** update yargs-parser to move off a flagged-vulnerable version. ([#635](https://github.com/conventional-changelog/conventional-changelog/issues/635)) ([aafc0f0](https://github.com/conventional-changelog/conventional-changelog/commit/aafc0f00412c3e4b23b8418300e5a570a48fe24d))
45
-
46
-
47
-
48
-
49
-
50
- ## [2.0.3](https://github.com/conventional-changelog/conventional-changelog/compare/git-raw-commits@2.0.2...git-raw-commits@2.0.3) (2019-11-14)
51
-
52
- **Note:** Version bump only for package git-raw-commits
53
-
54
-
55
-
56
-
57
-
58
- ## [2.0.2](https://github.com/conventional-changelog/conventional-changelog/compare/git-raw-commits@2.0.1...git-raw-commits@2.0.2) (2019-04-10)
59
-
60
-
61
- ### Bug Fixes
62
-
63
- * **deps:** update dependency through2 to v3 ([#392](https://github.com/conventional-changelog/conventional-changelog/issues/392)) ([26fe91f](https://github.com/conventional-changelog/conventional-changelog/commit/26fe91f))
64
-
65
-
66
-
67
-
68
-
69
- ## [2.0.1](https://github.com/conventional-changelog/conventional-changelog/compare/git-raw-commits@2.0.0...git-raw-commits@2.0.1) (2018-11-01)
70
-
71
-
72
- ### Bug Fixes
73
-
74
- * Upgrade to Lerna 3, fix Node.js v11 error ([#385](https://github.com/conventional-changelog/conventional-changelog/issues/385)) ([cdef282](https://github.com/conventional-changelog/conventional-changelog/commit/cdef282))
75
-
76
-
77
-
78
-
79
-
80
- <a name="2.0.0"></a>
81
- # [2.0.0](https://github.com/conventional-changelog/conventional-changelog/compare/git-raw-commits@1.3.6...git-raw-commits@2.0.0) (2018-05-29)
82
-
83
-
84
- ### Chores
85
-
86
- * **package:** set Node requirement to oldest supported LTS ([#329](https://github.com/conventional-changelog/conventional-changelog/issues/329)) ([cae2fe0](https://github.com/conventional-changelog/conventional-changelog/commit/cae2fe0))
87
-
88
-
89
- ### BREAKING CHANGES
90
-
91
- * **package:** Set the package's minimum required Node version to be the oldest LTS
92
- currently supported by the Node Release working group. At this time,
93
- that is Node 6 (which is in its Maintenance LTS phase).
94
-
95
-
96
-
97
-
98
- <a name="1.3.6"></a>
99
- ## [1.3.6](https://github.com/conventional-changelog/conventional-changelog/compare/git-raw-commits@1.3.5...git-raw-commits@1.3.6) (2018-03-27)
100
-
101
-
102
-
103
-
104
- **Note:** Version bump only for package git-raw-commits
105
-
106
- <a name="1.3.5"></a>
107
- ## [1.3.5](https://github.com/conventional-changelog/conventional-changelog/compare/git-raw-commits@1.3.4...git-raw-commits@1.3.5) (2018-03-22)
108
-
109
-
110
-
111
-
112
- **Note:** Version bump only for package git-raw-commits
113
-
114
- <a name="1.3.4"></a>
115
- ## [1.3.4](https://github.com/conventional-changelog/conventional-changelog/compare/git-raw-commits@1.3.3...git-raw-commits@1.3.4) (2018-02-24)
116
-
117
-
118
-
119
-
120
- **Note:** Version bump only for package git-raw-commits
121
-
122
- <a name="1.3.3"></a>
123
- ## [1.3.3](https://github.com/conventional-changelog/conventional-changelog/compare/git-raw-commits@1.3.2...git-raw-commits@1.3.3) (2018-02-20)
124
-
125
-
126
-
127
-
128
- **Note:** Version bump only for package git-raw-commits
129
-
130
- <a name="1.3.2"></a>
131
- ## [1.3.2](https://github.com/conventional-changelog/git-raw-commits/compare/git-raw-commits@1.3.1...git-raw-commits@1.3.2) (2018-02-13)
132
-
133
-
134
-
135
-
136
- **Note:** Version bump only for package git-raw-commits
137
-
138
- <a name="1.3.1"></a>
139
- ## [1.3.1](https://github.com/conventional-changelog/git-raw-commits/compare/git-raw-commits@1.3.0...git-raw-commits@1.3.1) (2018-02-13)
140
-
141
-
142
-
143
-
144
- **Note:** Version bump only for package git-raw-commits
145
-
146
- <a name="1.3.0"></a>
147
- # [1.3.0](https://github.com/conventional-changelog/git-raw-commits/compare/git-raw-commits@1.2.0...git-raw-commits@1.3.0) (2017-11-13)
148
-
149
-
150
- ### Features
151
-
152
- * **git-raw-commits:** add execOpts.cwd ([2631213](https://github.com/conventional-changelog/git-raw-commits/commit/2631213))
153
-
154
-
155
-
156
-
157
- <a name="1.2.0"></a>
158
- # [1.2.0](https://github.com/conventional-changelog/conventional-changelog/compare/git-raw-commits@1.1.2...v1.2.0) (2017-03-10)
159
-
160
-
161
- ### Features
162
-
163
- * allow raw commits to be filtered by path ([#172](https://github.com/conventional-changelog/conventional-changelog/issues/172)) ([ec0a25d](https://github.com/conventional-changelog/conventional-changelog/commit/ec0a25d))
164
- * migrate repo to lerna mono-repo ([793e823](https://github.com/conventional-changelog/conventional-changelog/commit/793e823))
165
-
166
- <a name="1.1.2"></a>
167
- ## [1.1.2](https://github.com/conventional-changelog/git-raw-commits/compare/v1.1.1...v1.1.2) (2016-06-27)
168
-
169
-
170
- ### Bug Fixes
171
-
172
- * **windows:** use execFile for executing git ([9ae06df](https://github.com/conventional-changelog/git-raw-commits/commit/9ae06df)), closes [#11](https://github.com/conventional-changelog/git-raw-commits/issues/11)
173
-
174
-
175
-
176
- <a name="1.1.1"></a>
177
- ## [1.1.1](https://github.com/conventional-changelog/git-raw-commits/compare/v1.1.0...v1.1.1) (2016-06-26)
178
-
179
-
180
- ### Bug Fixes
181
-
182
- * **windows:** escape command percent signs ([005b559](https://github.com/conventional-changelog/git-raw-commits/commit/005b559)), closes [#10](https://github.com/conventional-changelog/git-raw-commits/issues/10)