Skip to content

Commit

Permalink
Merge pull request neetcode-gh#985 from Ahmad-A0/main
Browse files Browse the repository at this point in the history
Make "Missing Solution" script check in nested directories.
  • Loading branch information
Ahmad-A0 authored Sep 1, 2022
2 parents b4fa78c + c02c169 commit b201d70
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion .github/workflows/updateCompletionTable.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const { readdirSync } = require('fs');
const fs = require("fs")
const path = require("path")

const IGNORE_DIRS = ['.github', '.git'];
const PREPEND_PATH = process.argv[2] || './';
Expand Down Expand Up @@ -490,14 +492,33 @@ const getDirectories = (source) =>
.filter((dirent) => dirent.isDirectory())
.map((dirent) => dirent.name);

function *walkSync(dir) {
const files = fs.readdirSync(dir, { withFileTypes: true });
for (const file of files) {
if (file.isDirectory()) {
yield* walkSync(path.join(dir, file.name));
} else {
yield path.join(dir, file.name);
}
}
}

function nestedFiles(dir) {
files = []
for (const filePath of walkSync(dir)) {
files.push(filePath)
}
return files
}

const buildTableColumn = (
language,
problems,
tableMatrix,
directory = False
) => {
directory = directory || language;
let files = readdirSync(directory);
let files = nestedFiles(directory)
let checkbox = problems.reduce((acc, [, number]) => {
acc[number] = false;
return acc;
Expand Down

0 comments on commit b201d70

Please sign in to comment.