Skip to content

Commit

Permalink
fix(nx-dev): update course API to ignore system OS Metadata file (#28886
Browse files Browse the repository at this point in the history
)

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes #
  • Loading branch information
ndcunningham authored Nov 12, 2024
1 parent c21b039 commit 1e1cd3a
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions nx-dev/data-access-courses/src/lib/courses.api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { readFile, readdir } from 'fs/promises';
import { join } from 'path';
import { extractFrontmatter } from '@nx/nx-dev/ui-markdoc';
import { readFileSync } from 'fs';
import { readFileSync, lstatSync } from 'fs';
import { Course, Lesson } from './course.types';
import { calculateTotalDuration } from './duration.utils';

Expand All @@ -22,7 +22,12 @@ export class CoursesApi {
async getAllCourses(): Promise<Course[]> {
const courseFolders = await readdir(this.options.coursesRoot);
const courses = await Promise.all(
courseFolders.map((folder) => this.getCourse(folder))
courseFolders
.filter((directory) => {
const stat = lstatSync(join(this.options.coursesRoot, directory));
return stat.isDirectory();
})
.map((folder) => this.getCourse(folder))
);
return courses;
}
Expand All @@ -40,7 +45,10 @@ export class CoursesApi {
const lessonFolders = await readdir(coursePath);
const lessons = await Promise.all(
lessonFolders
.filter((folder) => folder !== 'course.md')
.filter((folder) => {
const stat = lstatSync(join(coursePath, folder));
return stat.isDirectory();
})
.map((folder) => this.getLessons(folderName, folder))
);
const flattenedLessons = lessons.flat();
Expand Down

0 comments on commit 1e1cd3a

Please sign in to comment.