Skip to content

Commit 114d6cf

Browse files
committed
refactor: update file loop
1 parent c1b9e16 commit 114d6cf

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

example/documentation/code/config.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,19 +53,17 @@ export const generate = async (argv: Record<string, string>) => {
5353
if (!file.isDir && file.folder) {
5454
// path where file should be saved
5555
const dest = join(docsFolder, file.folder.replace(srcFolder, ''));
56+
let content;
5657

57-
switch (file.ext) {
58-
case '.tsx':
59-
case '.ts':
60-
case '.js':
61-
parsePromises.push(
62-
writeContentToFile(await parseFile(file, srcFolder, docsFolder, argv.jsDocConfigPath, partials), dest)
63-
);
64-
break;
65-
case '.jsx':
66-
case '.vue':
67-
parsePromises.push(writeContentToFile(await parseVueFile(file, srcFolder, docsFolder), dest));
68-
break;
58+
if (['.jsx', '.tsx', '.ts', '.js'].includes(file.ext || '')) {
59+
content = await parseFile(file, srcFolder, docsFolder, argv.jsDocConfigPath, partials);
60+
}
61+
if (file.ext === '.vue') {
62+
content = await parseVueFile(file, srcFolder, docsFolder);
63+
}
64+
65+
if (content) {
66+
parsePromises.push(writeContentToFile(content, dest));
6967
}
7068
}
7169
}
@@ -131,5 +129,5 @@ export const generate = async (argv: Record<string, string>) => {
131129

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

134-
console.log(`\n⏰ Time: ${resultTime}s\n`);
132+
console.log(`\n⏰ Time: ${resultTime}s`);
135133
};

0 commit comments

Comments
 (0)