Skip to content

Commit

Permalink
Fix new glob signature
Browse files Browse the repository at this point in the history
  • Loading branch information
willemliufdmg committed Mar 17, 2023
1 parent 12d0e11 commit 741d20b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 24 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"dogfood": "dotenv fiu -- -v -s -i ./images",
"dogfood2": "dotenv fiu -- -v -s -i ./public/images",
"help": "node -r dotenv/config dist/app.js --help",
"start": "node -r dotenv/config dist/app.js -o ./imageMap.json -i ./images -s",
"start": "node -r dotenv/config dist/app.js -e development -o ./imageMap.json -i ./images -s",
"start2": "node -r dotenv/config dist/app.js -e acceptance -o ./imageMap.json -i ./public/images -s",
"release:fdmg": "node modifyPackageJson.js -s @fdmg",
"release:fdmediagroep": "node modifyPackageJson.js -s @fdmediagroep",
Expand Down
40 changes: 17 additions & 23 deletions src/utils/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,21 @@ import { glob } from "glob";
* of all the files in given location (dir).
*/
export async function getFiles(dir: string) {
const promise = new Promise<{ fileName: string; absolutePath: string }[]>(
(resolve, reject) => {
const results: { fileName: string; absolutePath: string }[] = [];
glob(
`${dir}/**/*`,
{ nodir: true, absolute: true },
function (er, files) {
if (er) {
reject();
}
files.forEach((absolutePath) => {
const pathSplits = absolutePath.split("/");
results.push({
fileName: pathSplits[pathSplits.length - 1],
absolutePath,
});
});
resolve(results);
}
);
}
);
return promise;
const results: { fileName: string; absolutePath: string }[] = [];
try {
const files = await glob(`${dir}/**/*`, {
nodir: true,
absolute: true,
});
files.forEach((absolutePath) => {
const pathSplits = absolutePath.split("/");
results.push({
fileName: pathSplits[pathSplits.length - 1],
absolutePath,
});
});
} catch (e) {
throw e;
}
return results;
}

0 comments on commit 741d20b

Please sign in to comment.