Skip to content

Commit

Permalink
Merge pull request #66 from tuatmcc/fix/skipping
Browse files Browse the repository at this point in the history
[fix]: file skipping
  • Loading branch information
OJII3 authored Nov 17, 2023
2 parents 83cafb6 + 9783edf commit 6330df0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 22 deletions.
1 change: 0 additions & 1 deletion src/mdorganizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export class MdOrganizer {

async generateAllModules(): Promise<void> {
const categoryModules = await this.moduleGenerator.generateAll();
console.log(categoryModules);
for (const categoryModule of categoryModules) {
for (const doc of categoryModule.documentModules) {
await writeFile(
Expand Down
41 changes: 20 additions & 21 deletions src/modulegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,26 @@ export class ModuleGenerator {
for (const categoryConfig of this.categoryConfigs) {
const paths = await glob(categoryConfig.globPattern);
// generate modules for each document
const documentModules = await Promise.all(
paths
.map(async (path) => {
try {
return {
rootPath: path,
documentId: `${path
.replace(/\\/g, '/')
.replaceAll('/', '_')
.replace('.md', '')}`,
generatedModuleString: await this.generate(
path,
categoryConfig,
),
} satisfies DocumentModule;
} catch (e) {
console.log(`Skipping ${path} due to error: ${e.message}`);
return null;
}
})
.filter((documentModule) => documentModule !== null),
let documentModules = await Promise.all(
paths.map(async (path) => {
try {
return {
rootPath: path,
documentId: `${path
.replace(/\\/g, '/')
.replaceAll('/', '_')
.replace('.md', '')}`,
generatedModuleString: await this.generate(path, categoryConfig),
} satisfies DocumentModule;
} catch (e) {
console.log(`Skipping ${path} due to error: ${e.message}`);
return null;
}
}),
);

documentModules = documentModules.filter(
(documentModule) => documentModule !== null,
);

console.log(
Expand Down

0 comments on commit 6330df0

Please sign in to comment.