Skip to content
This repository has been archived by the owner on Feb 5, 2018. It is now read-only.

Commit

Permalink
fix(cli): commit can be split when testing a commit file
Browse files Browse the repository at this point in the history
  • Loading branch information
stevemao committed Mar 7, 2015
1 parent 0be93a7 commit e02c289
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,38 @@ An array of json will be printed to stdout.
]
```

Commits should be split by at least three newlines (`\n\n\n`) or you can specify a separator as the second argument.

Eg: in log2.txt

```text
2d0eda10e43f6b079b531c507282fad082ea0762
docs(ngMessageExp): split ngMessage docs up to show its alias more clearly
===
4374f892c6fa4af6ba1f2ed47c5f888fdb5fadc5
fix($animate): applyStyles from options on leave
Closes #10068
```

And you run

```sh
conventional-commits-parser log2.txt '==='
```

```sh
[
{"hash":"2d0eda10e43f6b079b531c507282fad082ea0762","header":"docs(ngMessageExp): split ngMessage docs up to show its alias more clearly","body":"","footer":"","breaks":{},"closes":[],"type":"docs","scope":"ngMessageExp","subject":"split ngMessage docs up to show its alias more clearly"}
,
{"hash":"4374f892c6fa4af6ba1f2ed47c5f888fdb5fadc5","header":"fix($animate): applyStyles from options on leave","body":"","footer":"Closes #10068","breaks":{},"closes":[10068],"type":"fix","scope":"$animate","subject":"applyStyles from options on leave"}
]
```

Will be printed out.


## License

Expand Down
2 changes: 2 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
var conventionalCommitsParser = require('./');
var JSONStream = require('JSONStream');
var meow = require('meow');
var split = require('split');

var cli = meow({
help: [
Expand All @@ -23,6 +24,7 @@ if (cli.input.length > 0) {
.on('error', function(err) {
console.log('Failed to read file ' + cli.input[0] + '\n' + err);
})
.pipe(split(cli.input[1] || '\n\n\n'))
.pipe(conventionalCommitsParser(cli.flags))
.pipe(JSONStream.stringify())
.pipe(process.stdout);
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"JSONStream": "^0.10.0",
"graceful-fs": "^3.0.5",
"meow": "^3.1.0",
"split": "^0.3.3",
"through2": "^0.6.3"
},
"devDependencies": {
Expand Down

0 comments on commit e02c289

Please sign in to comment.