Files
buzz/beehive/src/setup-path.ts
2026-09-10 16:08:34 -04:00

9 lines
471 B
TypeScript

import { homedir } from 'node:os';
import { resolve } from 'node:path';
/** Resolve an explicitly supplied local path, including conventional ~/ spelling. */
export function setupPath(value: string): string {
if (value.startsWith('~') && value !== '~' && !value.startsWith('~/')) throw Error('Use ~ or ~/ for your home; ~user paths are not supported');
return resolve(value === '~' ? homedir() : value.startsWith('~/') ? `${homedir()}/${value.slice(2)}` : value);
}