Skip to content

Commit 54d1f70

Browse files
committed
refactor(session): extract scoped DerivedData path helper
Move the workspace/project-scoped DerivedData computation out of SessionStore.getAllForProfile into a module-private computeScopedDerivedDataPath helper. The getter now reads as a single boolean-and-assign, isolating the resolve/hash/basename mechanics.
1 parent ab4fa58 commit 54d1f70

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/utils/session-store.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ export type SessionDefaults = {
2626
env?: Record<string, string>;
2727
};
2828

29+
function computeScopedDerivedDataPath(anchor: string): string {
30+
const resolved = path.resolve(anchor);
31+
const hash = crypto.createHash('sha256').update(resolved).digest('hex').slice(0, 12);
32+
const name = path.basename(resolved, path.extname(resolved));
33+
return path.join(DERIVED_DATA_DIR, `${name}-${hash}`);
34+
}
35+
2936
class SessionStore {
3037
private globalDefaults: SessionDefaults = {};
3138
private profiles: Record<string, SessionDefaults> = {};
@@ -140,10 +147,7 @@ class SessionStore {
140147
if (!result.derivedDataPath) {
141148
const anchor = result.workspacePath ?? result.projectPath;
142149
if (anchor) {
143-
const resolved = path.resolve(anchor);
144-
const hash = crypto.createHash('sha256').update(resolved).digest('hex').slice(0, 12);
145-
const name = path.basename(resolved, path.extname(resolved));
146-
result.derivedDataPath = path.join(DERIVED_DATA_DIR, `${name}-${hash}`);
150+
result.derivedDataPath = computeScopedDerivedDataPath(anchor);
147151
}
148152
}
149153

0 commit comments

Comments
 (0)