Skip to content

Commit 99b2036

Browse files
committed
feat: expose getRemoteOrigin and other methods, close #1
1 parent 424ca92 commit 99b2036

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,19 @@ Notes:
4040
- If a command fails, returns empty string for each property
4141
- If you need to debug, run with `DEBUG=commit-info` environment variable.
4242

43+
## Individual methods
44+
45+
In addition to `commitInfo` this module also exposes individual promise-returning
46+
methods `getBranch`, `getMessage`, `getEmail`, `getAuthor`, `getSha`, `getRemoteOrigin`.
47+
48+
For example
49+
50+
```js
51+
const {getAuthor} = require('@cypress/commit-info')
52+
getAuthor('path/to/repo')
53+
.then(name => ...)
54+
```
55+
4356
### Small print
4457

4558
License: MIT - do anything with the code, but don't blame me if it does not work.

src/commit-info-spec.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ const { commitInfo } = require('.')
55
const { stubSpawnShellOnce } = require('stub-spawn-once')
66
const snapshot = require('snap-shot-it')
77
const { gitCommands } = require('./utils')
8+
const la = require('lazy-ass')
9+
const is = require('check-more-types')
810

911
describe('commit-info', () => {
1012
const env = process.env
@@ -41,4 +43,9 @@ describe('commit-info', () => {
4143
stubSpawnShellOnce(gitCommands.remoteOriginUrl, 1, '', 'no remote origin')
4244
return commitInfo().then(snapshot)
4345
})
46+
47+
it('has getRemoteOrigin method', () => {
48+
const { getRemoteOrigin } = require('.')
49+
la(is.fn(getRemoteOrigin))
50+
})
4451
})

src/index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,12 @@ function commitInfo (folder) {
2626
})
2727
}
2828

29-
module.exports = { commitInfo }
29+
module.exports = {
30+
commitInfo,
31+
getBranch,
32+
getMessage,
33+
getEmail,
34+
getAuthor,
35+
getSha,
36+
getRemoteOrigin
37+
}

0 commit comments

Comments
 (0)