Skip to content

Commit

Permalink
fix(deps): update dependency glob to ^10.1.0 (#555)
Browse files Browse the repository at this point in the history
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Tony Brix <tony@brix.ninja>
  • Loading branch information
renovate[bot] and UziTech committed Apr 15, 2023
1 parent 1c3e750 commit 196c925
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 22 deletions.
5 changes: 3 additions & 2 deletions lib/express-handlebars.ts
Expand Up @@ -311,7 +311,7 @@ export default class ExpressHandlebars {
let dir = options.cache && (cache[dirPath] as Promise<string[]>);

if (dir) {
return (await dir).concat();
return [...await dir];
}

const pattern = "**/*" + this.extname;
Expand All @@ -323,13 +323,14 @@ export default class ExpressHandlebars {
dir = cache[dirPath] = glob(pattern, {
cwd: dirPath,
follow: true,
posix: true,
});
// @ts-expect-error FIXME: not sure how to throw error in glob for test coverage
if (options._throwTestError) {
throw new Error("test");
}

return (await dir).map(d => d.replace(/\\/g, "/"));
return [...await dir];
} catch (err) {
delete cache[dirPath];
throw err;
Expand Down
30 changes: 15 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -24,7 +24,7 @@
"node": ">=v16"
},
"dependencies": {
"glob": "^10.0.0",
"glob": "^10.1.0",
"graceful-fs": "^4.2.11",
"handlebars": "^4.7.7"
},
Expand Down
9 changes: 5 additions & 4 deletions spec/express-handlebars.test.ts
Expand Up @@ -633,17 +633,18 @@ describe("express-handlebars", () => {
test("should get from cache", async () => {
const exphbs = expressHandlebars.create();
const filePath = fixturePath("test");
exphbs._fsCache[filePath] = "test";
exphbs._fsCache[filePath] = Promise.resolve(["test"]);
const file = await exphbs["_getDir"](filePath, { cache: true });
expect(file).toBe("test");
expect(file).toEqual(["test"]);
});

test("should store in cache", async () => {
const exphbs = expressHandlebars.create();
const filePath = fixturePath("templates");
expect(exphbs._fsCache[filePath]).toBeUndefined();
await exphbs["_getDir"](filePath);
expect(exphbs._fsCache[filePath]).toBeDefined();
const expected = await exphbs["_getDir"](filePath);
expect(exphbs._fsCache[filePath]).toBeInstanceOf(Promise);
expect(await exphbs._fsCache[filePath]).toEqual(expected);
});

test("should not store in cache on error", async () => {
Expand Down

0 comments on commit 196c925

Please sign in to comment.