Skip to content

Commit

Permalink
refactor: update file loop
Browse files Browse the repository at this point in the history
  • Loading branch information
ph1p committed Sep 2, 2021
1 parent c1b9e16 commit 114d6cf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
2 changes: 1 addition & 1 deletion example/documentation/code/config.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 11 additions & 13 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,17 @@ export const generate = async (argv: Record<string, string>) => {
if (!file.isDir && file.folder) {
// path where file should be saved
const dest = join(docsFolder, file.folder.replace(srcFolder, ''));
let content;

switch (file.ext) {
case '.tsx':
case '.ts':
case '.js':
parsePromises.push(
writeContentToFile(await parseFile(file, srcFolder, docsFolder, argv.jsDocConfigPath, partials), dest)
);
break;
case '.jsx':
case '.vue':
parsePromises.push(writeContentToFile(await parseVueFile(file, srcFolder, docsFolder), dest));
break;
if (['.jsx', '.tsx', '.ts', '.js'].includes(file.ext || '')) {
content = await parseFile(file, srcFolder, docsFolder, argv.jsDocConfigPath, partials);
}
if (file.ext === '.vue') {
content = await parseVueFile(file, srcFolder, docsFolder);
}

if (content) {
parsePromises.push(writeContentToFile(content, dest));
}
}
}
Expand Down Expand Up @@ -131,5 +129,5 @@ export const generate = async (argv: Record<string, string>) => {

const resultTime = (Math.abs(startTime - +new Date()) / 1000).toFixed(2);

console.log(`\n⏰ Time: ${resultTime}s\n`);
console.log(`\n⏰ Time: ${resultTime}s`);
};

0 comments on commit 114d6cf

Please sign in to comment.