fix(nx-dev): update course API to ignore system OS Metadata file (#28886)
<!-- 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 #
This commit is contained in:
parent
c21b039dd0
commit
1e1cd3a0c5
@ -1,7 +1,7 @@
|
|||||||
import { readFile, readdir } from 'fs/promises';
|
import { readFile, readdir } from 'fs/promises';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { extractFrontmatter } from '@nx/nx-dev/ui-markdoc';
|
import { extractFrontmatter } from '@nx/nx-dev/ui-markdoc';
|
||||||
import { readFileSync } from 'fs';
|
import { readFileSync, lstatSync } from 'fs';
|
||||||
import { Course, Lesson } from './course.types';
|
import { Course, Lesson } from './course.types';
|
||||||
import { calculateTotalDuration } from './duration.utils';
|
import { calculateTotalDuration } from './duration.utils';
|
||||||
|
|
||||||
@ -22,7 +22,12 @@ export class CoursesApi {
|
|||||||
async getAllCourses(): Promise<Course[]> {
|
async getAllCourses(): Promise<Course[]> {
|
||||||
const courseFolders = await readdir(this.options.coursesRoot);
|
const courseFolders = await readdir(this.options.coursesRoot);
|
||||||
const courses = await Promise.all(
|
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;
|
return courses;
|
||||||
}
|
}
|
||||||
@ -40,7 +45,10 @@ export class CoursesApi {
|
|||||||
const lessonFolders = await readdir(coursePath);
|
const lessonFolders = await readdir(coursePath);
|
||||||
const lessons = await Promise.all(
|
const lessons = await Promise.all(
|
||||||
lessonFolders
|
lessonFolders
|
||||||
.filter((folder) => folder !== 'course.md')
|
.filter((folder) => {
|
||||||
|
const stat = lstatSync(join(coursePath, folder));
|
||||||
|
return stat.isDirectory();
|
||||||
|
})
|
||||||
.map((folder) => this.getLessons(folderName, folder))
|
.map((folder) => this.getLessons(folderName, folder))
|
||||||
);
|
);
|
||||||
const flattenedLessons = lessons.flat();
|
const flattenedLessons = lessons.flat();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user