Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add parameter to change output HTML file name #86

Merged
merged 3 commits into from
Oct 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ npm install -g @asyncapi/generator
|sidebarOrganization|Defines how the sidebar should be organized. Set its value to `byTagsNoRoot` to categorize operations by operations tags. Set its value to `byTags` when you have tags on a root level. These tags are used to model tags navigation and need to have the same tags in operations.|No|`byTags`, `byTagsNoRoot`|`byTagsNoRoot`|
|baseHref|Sets the base URL for links and forms.|No|*Any*|`/docs`|
|singleFile|Set output into one html-file with styles and scripts inside|No|`true`,`false`|`true`|
|outFilename|The filename of the output file.|No|*Any*|`asyncapi.html`|

## Development

Expand Down
10 changes: 10 additions & 0 deletions hooks/02_renameOutFile.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 !== 'index.html') {
fs.renameSync(`${generator.targetDir}/index.html`,
`${generator.targetDir}/${generator.templateParams.outFilename}`);
}
}
}
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@
"description": "If set this parameter to true generate single html file with scripts and styles inside",
"required": false,
"default": false
},
"outFilename": {
"description": "The name of the output HTML file",
"default": "index.html",
"required": false
}
},
"generator": ">=0.50.0 <2.0.0",
Expand Down