UNPKG

@liara/cli

Version:

The command line interface for Liara

37 lines (36 loc) 944 B
import os from 'node:os'; import path from 'node:path'; const checkPath = (dir) => { if (!dir) { return; } const home = os.homedir(); let location = ''; dir = dir.replace(/\/+$/, ''); // trim end slashes const paths = { home, desktop: path.join(home, 'Desktop'), downloads: path.join(home, 'Downloads'), }; for (const locationPath of Object.keys(paths)) { if (dir === paths[locationPath]) { location = locationPath; } } if (!location) { return; } let locationName; switch (location) { case 'home': locationName = 'user directory'; break; case 'downloads': locationName = 'downloads directory'; break; default: locationName = location; } throw new Error(`You're trying to deploy your ${locationName}.`); }; export default checkPath;