(cwd)
| 27 | } |
| 28 | |
| 29 | export function resolveStateDir(cwd) { |
| 30 | const workspaceRoot = resolveWorkspaceRoot(cwd); |
| 31 | let canonicalWorkspaceRoot = workspaceRoot; |
| 32 | try { |
| 33 | canonicalWorkspaceRoot = fs.realpathSync.native(workspaceRoot); |
| 34 | } catch { |
| 35 | canonicalWorkspaceRoot = workspaceRoot; |
| 36 | } |
| 37 | |
| 38 | const slugSource = path.basename(workspaceRoot) || "workspace"; |
| 39 | const slug = slugSource.replace(/[^a-zA-Z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "workspace"; |
| 40 | const hash = createHash("sha256").update(canonicalWorkspaceRoot).digest("hex").slice(0, 16); |
| 41 | const pluginDataDir = process.env[PLUGIN_DATA_ENV]; |
| 42 | const stateRoot = pluginDataDir ? path.join(pluginDataDir, "state") : FALLBACK_STATE_ROOT_DIR; |
| 43 | return path.join(stateRoot, `${slug}-${hash}`); |
| 44 | } |
| 45 | |
| 46 | export function resolveStateFile(cwd) { |
| 47 | return path.join(resolveStateDir(cwd), STATE_FILE_NAME); |
no test coverage detected