ttsc
Version:
General-purpose TypeScript-Go compiler, runtime, plugin host, and LSP host.
21 lines (19 loc) • 643 B
text/typescript
import path from "node:path";
/**
* Resolve a user-supplied `--cache-dir` value into an absolute path.
*
* When `cacheDir` is absent or empty, returns `undefined` so callers fall
* through to the `TTSC_CACHE_DIR` environment variable and the workspace-local
* default handled inside `buildSourcePlugin`. When `cacheDir` is already
* absolute it is returned unchanged; otherwise it is resolved relative to
* `cwd`.
*/
export function resolveCacheDir(
cwd: string,
cacheDir?: string,
): string | undefined {
if (!cacheDir) {
return undefined;
}
return path.isAbsolute(cacheDir) ? cacheDir : path.resolve(cwd, cacheDir);
}