forked from storybookjs/addon-webpack5-compiler-babel
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.ts
More file actions
22 lines (19 loc) · 760 Bytes
/
utils.ts
File metadata and controls
22 lines (19 loc) · 760 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { join } from "node:path";
import findCacheDirectory from "find-cache-dir";
/**
* Get the path of the file or directory with input name inside the Storybook cache directory:
*
* - `node_modules/.cache/storybook/{directoryName}` in a Node.js project or npm package
* - `.cache/storybook/{directoryName}` otherwise
*
* @param fileOrDirectoryName {string} Name of the file or directory
* @returns {string} Absolute path to the file or directory
*/
export function resolvePathInStorybookCache(
fileOrDirectoryName: string,
sub = "default",
): string {
let cacheDirectory = findCacheDirectory({ name: "storybook" });
cacheDirectory ||= join(process.cwd(), ".cache", "storybook");
return join(cacheDirectory, sub, fileOrDirectoryName);
}