Skip to content

Commit 19c4a01

Browse files
committed
chore: code review changes
1 parent bf4004e commit 19c4a01

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

src/loader.mjs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,21 @@ const createLoader = () => {
1515
/**
1616
* Loads API Doc files and transforms it into VFiles
1717
*
18-
* @param {string} path A glob/path for API docs to be loaded
18+
* @param {string} searchPath A glob/path for API docs to be loaded
1919
* The input string can be a simple path (relative or absolute)
2020
* The input string can also be any allowed glob string
2121
*
2222
* @see https://code.visualstudio.com/docs/editor/glob-patterns
2323
*/
24-
const loadFiles = path => {
25-
const resolvedFiles = globSync(path);
24+
const loadFiles = searchPath => {
25+
const resolvedFiles = globSync(searchPath).filter(
26+
filePath => extname(filePath) === '.md'
27+
);
2628

2729
return resolvedFiles.map(async filePath => {
28-
const fileExtension = extname(filePath);
30+
const fileBuffer = await readFile(filePath);
2931

30-
if (fileExtension === '.md') {
31-
const fileBuffer = await readFile(filePath);
32-
33-
return new VFile({ path: filePath, value: fileBuffer });
34-
}
35-
36-
throw new Error(`File ${filePath} is not a Markdown file`);
32+
return new VFile({ path: filePath, value: fileBuffer });
3733
});
3834
};
3935

src/metadata.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const createMetadata = slugger => {
3333
},
3434
/**
3535
* Set the Metadata (from YAML if exists) properties to the current Metadata entry
36-
* itI also allows for extra data (such as Stability Index) and miscellaneous data to be set
36+
* it also allows for extra data (such as Stability Index) and miscellaneous data to be set
3737
* although it'd be best to only set ones from {ApiDocRawMetadataEntry}
3838
*
3939
* @param {Partial<import('./types.d.ts').ApiDocRawMetadataEntry>} properties Extra Metadata properties to be defined

0 commit comments

Comments
 (0)