-
Notifications
You must be signed in to change notification settings - Fork 490
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
Generate Epic README.md #199
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,15 +44,32 @@ class ProfileGenerator { | |
*/ | ||
generateReadmeFile() { | ||
const template = fs.readFileSync(README_TEMPLATE_FILE_PATH, 'utf8'); | ||
const data = { | ||
getFloorMap, | ||
getFloorMapKey, | ||
profile: this.profile, | ||
level: this.level, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You just need to change the |
||
}; | ||
const levels = []; | ||
|
||
const options = { filename: README_TEMPLATE_FILE_PATH }; | ||
const renderedReadme = ejs.render(template, data, options); | ||
fs.writeFileSync(this.profile.getReadmeFilePath(), renderedReadme); | ||
if (this.profile.epic) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should use |
||
for (let i = 1; i < 10; i += 1) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check my comments here explaining what we should use for the loop. |
||
const data = { | ||
getFloorMap, | ||
getFloorMapKey, | ||
profile: this.profile, | ||
level: i, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're just passing the level number here, where we need the level config object instead. Check what we pass inside |
||
}; | ||
levels.push(data); | ||
} | ||
const renderedReadme = ejs.render(template, levels, options); | ||
fs.writeFileSync(this.profile.getReadmeFilePath(), renderedReadme); | ||
} else { | ||
const data = { | ||
getFloorMap, | ||
getFloorMapKey, | ||
profile: this.profile, | ||
level: this.level, | ||
}; | ||
levels.push(data); | ||
const renderedReadme = ejs.render(template, levels, options); | ||
fs.writeFileSync(this.profile.getReadmeFilePath(), renderedReadme); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The data object and the last two lines of this method can be moved outside the if/else blocks. The overall structure of the const template = fs.readFileSync(README_TEMPLATE_FILE_PATH, 'utf8');
const data = {
getFloorMap,
getFloorMapKey,
profile: this.profile,
};
if (this.profile.isEpic()) {
data.levels = ... // <-- Here you assemble the array of levels (all the levels)
} else {
data.levels = ... // <-- Here you assemble the array of levels (only one level in this case)
}
const options = { filename: README_TEMPLATE_FILE_PATH };
const renderedReadme = ejs.render(template, data, options);
fs.writeFileSync(this.profile.getReadmeFilePath(), renderedReadme); |
||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,9 @@ | |
<% } -%> | ||
|
||
## Level <%- level.number %> | ||
<% levels.forEach(level => { -%> | ||
<%- include('levels', { level }); %> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need to use the exact include line below instead of |
||
<% }); -%> | ||
|
||
<%- include('readme/level', { getFloorMap, getFloorMapKey, level }); -%> | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍