Skip to content

Commit

Permalink
feat: Add parameter to change output file name (#24)
Browse files Browse the repository at this point in the history
Co-authored-by: Lukasz Gornicki <lpgornicki@gmail.com>
  • Loading branch information
schw4rzlicht and derberg authored Jun 2, 2020
1 parent 02244d9 commit e2f311e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ If you don't have the AsyncAPI Generator installed, you can install it like this
```
npm install -g @asyncapi/generator
```
## Supported parameters

|Name|Description|Required|Default|Example|
|---|---|---|---|
|outFilename|The filename of the output file.|No|`asyncapi.md`|`index.md`|

## Development

Expand All @@ -40,4 +45,4 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
10 changes: 10 additions & 0 deletions hooks/output-filename.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const fs = require('fs');

module.exports = {
'generate:after': generator => {
if(generator.templateParams.outFilename !== 'asyncapi.md') {
fs.renameSync(`${generator.targetDir}/asyncapi.md`,
`${generator.targetDir}/${generator.templateParams.outFilename}`);
}
}
}
9 changes: 8 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@
"generator": ">=0.50.0 <2.0.0",
"filters": [
"@asyncapi/generator-filters"
]
],
"parameters": {
"outFilename": {
"description": "The name of the output markdown file",
"default": "asyncapi.md",
"required": false
}
}
}
}

0 comments on commit e2f311e

Please sign in to comment.