You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
859 B

// 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)
}