mirror of
https://github.com/block/buzz.git
synced 2026-10-29 13:31:44 +00:00
9 lines
471 B
TypeScript
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);
|
|
}
|