// Native import os from 'os' import path from 'path' // Ours import {error} from '../error' export default async dir => { if (!dir) { return } const home = os.homedir() let location const paths = { home, desktop: path.join(home, 'Desktop'), downloads: path.join(home, 'Downloads') } for (const locationPath in paths) { if (!{}.hasOwnProperty.call(paths, locationPath)) { continue } 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 } error(`You're trying to deploy your ${locationName}.`) process.exit(1) }