Skip to content

Commit 5dc317a

Browse files
committed
Fix cache location
1 parent a9f2d74 commit 5dc317a

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

packages/knip/src/util/file-entry-cache.ts

+2-8
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ import fs from 'node:fs';
77
// biome-ignore lint/nursery/noRestrictedImports: ignore
88
import path from 'node:path';
99
import { timerify } from './Performance.js';
10-
import parsedArgValues from './cli-arguments.js';
1110
import { debugLog } from './debug.js';
1211
import { isDirectory, isFile } from './fs.js';
13-
import { dirname, isAbsolute, resolve } from './path.js';
12+
import { cwd, dirname, isAbsolute, resolve } from './path.js';
1413
import { deserialize, serialize } from './serialize.js';
1514

1615
type MetaData<T> = { size: number; mtime: number; data?: T };
@@ -23,8 +22,6 @@ export type FileDescriptor<T> = {
2322
meta?: MetaData<T>;
2423
};
2524

26-
const cwd = process.cwd();
27-
2825
const createCache = (filePath: string) => {
2926
try {
3027
return deserialize(fs.readFileSync(filePath));
@@ -41,10 +38,7 @@ export class FileEntryCache<T> {
4138
normalizedEntries = new Map<string, FileDescriptor<T>>();
4239

4340
constructor(cacheId: string, _path: string) {
44-
const { 'cache-location': cacheLocation } = parsedArgValues;
45-
const currentPath = cacheLocation ? path.resolve(cacheLocation) : path.resolve(cwd);
46-
this.filePath = isAbsolute(currentPath) ? path.join(currentPath, cacheId) : path.join(currentPath, _path, cacheId);
47-
41+
this.filePath = isAbsolute(_path) ? path.resolve(_path, cacheId) : path.resolve(cwd, _path, cacheId);
4842
if (isFile(this.filePath)) this.cache = create(this.filePath);
4943
this.removeNotFoundFiles();
5044
}

0 commit comments

Comments
 (0)