Browse Source

Throw an error if current path doesn't exist

This closes #598
master
Leo Lamprecht 8 years ago
parent
commit
3411f7f066
  1. 19
      bin/now.js
  2. 12
      link/link.js

19
bin/now.js

@ -1,13 +1,30 @@
#!/usr/bin/env node
// Native
const fs = require('fs-extra')
const { resolve } = require('path')
// Packages
const updateNotifier = require('update-notifier')
const chalk = require('chalk')
// Ours
// Check if the current path exists and throw and error
// if the user is trying to deploy a non-existing path!
// This needs to be done exactly in this place, because
// the utility imports are taking advantage of it
try {
process.cwd()
} catch (err) {
if (err.code === 'ENOENT' && err.syscall === 'uv_cwd') {
console.log(`Current path doesn't exist!`)
} else {
console.log(err)
}
process.exit(1)
}
// Utilities
const pkg = require('../lib/pkg')
if (!process.pkg) {

12
link/link.js

@ -1,3 +1,11 @@
#!/usr/bin/env node
// eslint-disable-next-line import/no-unassigned-import
require('../bin/now.js');
try {
// eslint-disable-next-line import/no-unassigned-import
require('../bin/now.js')
} catch (err) {
if (err.code === 'ENOENT' && err.syscall === 'uv_cwd') {
console.error(`Current path doesn't exist!`)
process.exit(1)
}
}

Loading…
Cancel
Save