Skip to content

Commit

Permalink
fix: nondeterminism in file reading order (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
nornagon authored and MarshallOfSound committed Jun 12, 2019
1 parent e56144c commit 0c29cfc
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@ async function getAllMarkdownFiles(inDir: string) {
const allMarkdownFiles: string[] = [];

const children = await fs.readdir(inDir);
await Promise.all(
children.map(async child => {
const childPath = path.resolve(inDir, child);
const stats = await fs.stat(childPath);
if (path.extname(childPath) === '.md' && stats.isFile()) {
allMarkdownFiles.push(childPath);
}
}),
);
for (const child of children) {
const childPath = path.resolve(inDir, child);
const stats = await fs.stat(childPath);
if (path.extname(childPath) === '.md' && stats.isFile()) {
allMarkdownFiles.push(childPath);
}
}

return allMarkdownFiles;
}
Expand Down

0 comments on commit 0c29cfc

Please sign in to comment.