Skip to content

Commit 3b280e6

Browse files
dbehmoarasDavid Behmoaras
and
David Behmoaras
authoredDec 18, 2024··
Support caching results on Win32-based systems (#832)
Co-authored-by: David Behmoaras <davidbehmoaras@Davids-MacBook-Air.local>
1 parent ea478f5 commit 3b280e6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed
 

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

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
* - https://github.com/jaredwray/cacheable/blob/main/packages/file-entry-cache/LICENSE
55
*/
66
import fs from 'node:fs';
7+
// biome-ignore lint/nursery/noRestrictedImports: ignore
8+
import path from 'node:path';
79
import { timerify } from './Performance.js';
10+
import parsedArgValues from './cli-arguments.js';
811
import { debugLog } from './debug.js';
912
import { isDirectory, isFile } from './fs.js';
1013
import { dirname, isAbsolute, resolve } from './path.js';
@@ -38,7 +41,10 @@ export class FileEntryCache<T> {
3841
normalizedEntries = new Map<string, FileDescriptor<T>>();
3942

4043
constructor(cacheId: string, _path: string) {
41-
this.filePath = isAbsolute(_path) ? resolve(_path, cacheId) : resolve(cwd, _path, cacheId);
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+
4248
if (isFile(this.filePath)) this.cache = create(this.filePath);
4349
this.removeNotFoundFiles();
4450
}

0 commit comments

Comments
 (0)
Please sign in to comment.