Skip to content

Commit

Permalink
Merge pull request #51 from vordgi/ncm-50
Browse files Browse the repository at this point in the history
ncm-50 fix clearing old cache logic
  • Loading branch information
vordgi authored Jan 20, 2024
2 parents ce5592c + 8e080a8 commit a91f81d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next-classnames-minifier",
"version": "2.3.1",
"version": "2.3.2",
"description": "Library for configuring style modules to generate compressed classes",
"main": "dist/withClassnamesMinifier.js",
"types": "dist/withClassnamesMinifier.d.ts",
Expand Down
5 changes: 3 additions & 2 deletions src/lib/converters/ConverterMinified.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ class ConverterMinified implements ConverterBase {
const dirtyСache: CacheType = {};
let prevLastIndex = 0;
cachedFiles.forEach((file) => {
const dirtyCacheFile = readFileSync(path.join(cacheDir, file), { encoding: 'utf8' });
const filePath = path.join(cacheDir, file);
const dirtyCacheFile = readFileSync(filePath, { encoding: 'utf8' });
const [resourcePath, lastIndex, ...classnames] = dirtyCacheFile.split(',');
if (lastIndex && +lastIndex > prevLastIndex) prevLastIndex = +lastIndex;

Expand All @@ -74,7 +75,7 @@ class ConverterMinified implements ConverterBase {
type: 'old',
}
} else {
rmSync(resourcePath);
rmSync(filePath);
}
});

Expand Down

0 comments on commit a91f81d

Please sign in to comment.