Skip to content
This repository has been archived by the owner on Jun 17, 2021. It is now read-only.

Commit

Permalink
Merge branch 'release/1.4.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
Yago committed Jul 19, 2018
2 parents a4acfb8 + e910b32 commit f8ceff8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 24 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Toolbox Utils - CHANGELOG

*1.4.4* (2018-07-19)
- 🔨 simplify docs tree preparation (6b2b4ec)

*1.4.3* (2018-07-19)
- ✨ add documentation custom structure (6e0ef93)

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "toolbox-utils",
"version": "1.4.3",
"version": "1.4.4",
"description": "Resources for generator-toolbox",
"license": "MIT",
"engines": {
Expand Down
8 changes: 3 additions & 5 deletions tasks/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,22 @@ module.exports.projectPath = config.project;

const treeMaker = (dir) => {
return new Promise((resolve, reject) => {
const children = {};
const children = [];

fs.readdir(dir, async (err, list) => {
if (err) reject();
children.f = [];

for (let child of list) {
const childPath = `${dir}/${child}`;
const isDir = fs.lstatSync(childPath).isDirectory();


if (isDir) {
const subtree = await treeMaker(childPath);
children[child] = subtree;
children.push({ [child]: subtree });
} else {
const valideExts = ['.md', '.html'];
const fileExt = path.extname(child);
if (valideExts.includes(fileExt)) children.f.push(child);
if (valideExts.includes(fileExt)) children.push(child);
}
};

Expand Down
19 changes: 1 addition & 18 deletions tasks/prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,7 @@ const prepare = async (done) => {
let docFiles = {};
const summaryPath = `${config.project}/docs/summary.yml`;
if (fs.pathExistsSync(summaryPath)) {
// const summary = fs.readFileSync(summaryPath, 'utf8');
const summary = yaml.load(summaryPath);
const formatSummary = array => {
const output = {};
output.f = [];

array.forEach(item => {
if (typeof item === 'string') output.f.push(item);
if (typeof item === 'object') {
const key = Object.keys(item)[0];
output[key] = formatSummary(item[key]);
}
});

return output;
};

docFiles = formatSummary(summary);
docFiles = yaml.load(summaryPath);
} else {
docFiles = await dirTree(`${config.project}/docs`);
}
Expand Down

0 comments on commit f8ceff8

Please sign in to comment.