Skip to content

Commit

Permalink
feat: expose getRemoteOrigin and other methods, close #1
Browse files Browse the repository at this point in the history
  • Loading branch information
bahmutov committed Oct 28, 2017
1 parent 424ca92 commit 99b2036
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
13 changes: 13 additions & 0 deletions README.md
Expand Up @@ -40,6 +40,19 @@ Notes:
- If a command fails, returns empty string for each property
- If you need to debug, run with `DEBUG=commit-info` environment variable.

## Individual methods

In addition to `commitInfo` this module also exposes individual promise-returning
methods `getBranch`, `getMessage`, `getEmail`, `getAuthor`, `getSha`, `getRemoteOrigin`.

For example

```js
const {getAuthor} = require('@cypress/commit-info')
getAuthor('path/to/repo')
.then(name => ...)
```

### Small print

License: MIT - do anything with the code, but don't blame me if it does not work.
Expand Down
7 changes: 7 additions & 0 deletions src/commit-info-spec.js
Expand Up @@ -5,6 +5,8 @@ const { commitInfo } = require('.')
const { stubSpawnShellOnce } = require('stub-spawn-once')
const snapshot = require('snap-shot-it')
const { gitCommands } = require('./utils')
const la = require('lazy-ass')
const is = require('check-more-types')

describe('commit-info', () => {
const env = process.env
Expand Down Expand Up @@ -41,4 +43,9 @@ describe('commit-info', () => {
stubSpawnShellOnce(gitCommands.remoteOriginUrl, 1, '', 'no remote origin')
return commitInfo().then(snapshot)
})

it('has getRemoteOrigin method', () => {
const { getRemoteOrigin } = require('.')
la(is.fn(getRemoteOrigin))
})
})
10 changes: 9 additions & 1 deletion src/index.js
Expand Up @@ -26,4 +26,12 @@ function commitInfo (folder) {
})
}

module.exports = { commitInfo }
module.exports = {
commitInfo,
getBranch,
getMessage,
getEmail,
getAuthor,
getSha,
getRemoteOrigin
}

0 comments on commit 99b2036

Please sign in to comment.