Skip to content

Commit

Permalink
Exit if can't find local install of Gatsby
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleAMathews committed Sep 12, 2016
1 parent 84574b8 commit 030f655
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions bin/gatsby.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ var loadGatsby = function (path) {
require(path)
}

var loadGlobalGatsby = function () {
var useGlobalGatsby = function () {
var commandsToIgnore = ['new', '--help']
if (commandsToIgnore.indexOf(process.argv[2]) === -1) {
console.log(
"A local install of Gatsby was not found.\n" +
"Generally you should save Gatsby as a site dependency e.g. npm install --save gatsby\n" +
"Continuing with global install.\n\n"
"You should save Gatsby as a site dependency e.g. npm install --save gatsby"
)
process.exit()
}
fs.realpath(__dirname, function (err, real) {
if (err) throw err
Expand All @@ -47,16 +47,15 @@ var loadGlobalGatsby = function () {

fs.access(localPath, function (error) {
if (error) {
loadGlobalGatsby()
useGlobalGatsby()
} else {
try {
loadGatsby(localPath)
} catch(error) {
console.log(
'Gatsby: Local install exists but failed to load it. ' +
'Continuing with global install:', error
'Gatsby: Local install exists but failed to load it.'
)
loadGlobalGatsby()
console.log(error)
}
}
})

0 comments on commit 030f655

Please sign in to comment.