Skip to content
Open
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
26 changes: 10 additions & 16 deletions lib/summary/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,36 +83,30 @@ function Summary(options) {
function work(filesObj) {
_.forEach(filesObj, function(n, key) {
if (!_.includes(ignores, key)) {
if (_.isObject(n)) {
var formatLink = function(pathStr) {
var cleanPath = pathStr.replace(/[)\n\r]/g, '');
return "<" + cleanPath + ">)";
};

// It means folderName == subFileName, for example: */assets/assets.md or */Assets/assets.md
if (_.isObject(n)) {
if (_.isString(n[key]) || _.isString(n[key.toLowerCase()])) {
var file = n[key] || n[key.toLowerCase()];
desc += _.repeat(' ', step) + formatCatalog(key, '-') + file;

// Mark it to skip
desc += _.repeat(' ', step) + formatCatalog(key, '-') + formatLink(file) + "\n";
skip = key;
}

// The file is `readme.md`
else if (_.isString(n['readme']) || _.isString(n['Readme']) || _.isString(n['README'])) {
var readmeDir = n['readme'] || n['Readme'] || n['README'];
desc += _.repeat(' ', step) + formatCatalog(key, '-') + readmeDir.replace(/ /g, "%20");
desc += _.repeat(' ', step) + formatCatalog(key, '-') + formatLink(readmeDir) + "\n";
} else {
desc += _.repeat(' ', step) + "- " + prettyCatalogName(key) + "\n";
}

// Start a loop
step += 2;
work(n);
step -= 2;
} else {
// Skip if `skip` exists or key == `readme`
if (isSkiped(key, skip)) {
return;
}

desc += _.repeat(' ', step) + formatCatalog(key) + n.replace(/ /g, "%20");
if (isSkiped(key, skip)) return;

desc += _.repeat(' ', step) + formatCatalog(key) + formatLink(n) + "\n";
}
}
});
Expand Down
Loading