Browse Source

Don't deploy homedir, downloads or desktop

This closes #99
master
Leo Lamprecht 8 years ago
parent
commit
673b0dcd96
No known key found for this signature in database GPG Key ID: B08517883D5E0E10
  1. 4
      bin/now-deploy.js
  2. 47
      lib/utils/check-path.js

4
bin/now-deploy.js

@ -23,6 +23,7 @@ import promptOptions from '../lib/utils/prompt-options'
import {handleError, error} from '../lib/error'
import {fromGit, isRepoPath, gitPathParts} from '../lib/git'
import readMetaData from '../lib/read-metadata'
import checkPath from '../lib/utils/check-path'
const argv = minimist(process.argv.slice(2), {
string: [
@ -250,6 +251,9 @@ async function sync(token) {
}
}
// Make sure that directory is not too big
await checkPath(path)
if (!quiet) {
if (gitRepo.main) {
const gitRef = gitRepo.ref ? ` at "${chalk.bold(gitRepo.ref)}" ` : ''

47
lib/utils/check-path.js

@ -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…
Cancel
Save