Leo Lamprecht
8 years ago
2 changed files with 51 additions and 0 deletions
@ -0,0 +1,47 @@ |
|||
// 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 |
|||
} |
|||
} |
|||
|
|||
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) |
|||
} |
Loading…
Reference in new issue