Skip to content

Commit

Permalink
chore: disable cache during test
Browse files Browse the repository at this point in the history
  • Loading branch information
techfg authored and vernak2539 committed May 3, 2024
1 parent b76f496 commit 1bb5a41
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"pre-release": "yarn run changelog && yarn run prettier && yarn run generate-docs",
"generate-docs": "typedoc --readme none --gitRevision main --plugin typedoc-plugin-markdown src",
"prettier": "prettier ./src/** -w",
"test": "node --loader=esmock --test",
"test": "MATTER_CACHE_DISABLE=true node --loader=esmock --test",
"type-check": "tsc --noEmit --emitDeclarationOnly false"
},
"dependencies": {
Expand Down
5 changes: 4 additions & 1 deletion src/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -171,12 +171,15 @@ export function shouldProcessFile(npath) {

/** @type {Record<string, import('./utils.d.ts').MatterData>} */
const matterCache = {};
const matterCacheEnabled = process.env.MATTER_CACHE_DISABLE !== "true";
/** @type {import('./utils.d.ts').GetMatter} */
export function getMatter(npath) {
const readMatter = () => {
const content = readFileSync(npath);
const { data: frontmatter } = matter(content);
matterCache[npath] = frontmatter;
if (matterCacheEnabled) {
matterCache[npath] = frontmatter;
}
return frontmatter;
};

Expand Down

0 comments on commit 1bb5a41

Please sign in to comment.