Revert to previous way of checking Leiningen installation.

For Windows, check using where. If missing, throw error similar
to when running on OSX/Linux.
This commit is contained in:
Marcus Wangnusson 2016-02-01 19:26:41 +01:00
parent 2ea5143529
commit 5daf7989ac
1 changed files with 13 additions and 10 deletions

View File

@ -7,6 +7,7 @@
fs = require 'fs-extra' fs = require 'fs-extra'
net = require 'net' net = require 'net'
http = require 'http' http = require 'http'
os = require 'os'
crypto = require 'crypto' crypto = require 'crypto'
child = require 'child_process' child = require 'child_process'
cli = require 'commander' cli = require 'commander'
@ -45,12 +46,14 @@ exec = (cmd, keepOutput) ->
else else
child.execSync cmd, stdio: 'ignore' child.execSync cmd, stdio: 'ignore'
executableAvailable = (executable) -> ensureExecutableAvailable = (executable) ->
try if os.platform() == 'win32'
exec executable try
return true exec "where #{executable}"
catch catch e
return false throw new Error("type: #{executable}: not found")
else
exec "type #{executable}"
readFile = (path) -> readFile = (path) ->
fs.readFileSync path, encoding: 'ascii' fs.readFileSync path, encoding: 'ascii'
@ -281,9 +284,7 @@ init = (projName) ->
if fs.existsSync projNameHyph if fs.existsSync projNameHyph
throw new Error "Directory #{projNameHyph} already exists" throw new Error "Directory #{projNameHyph} already exists"
if not executableAvailable 'lein' ensureExecutableAvailable 'lein'
logErr 'Leiningen is required (http://leiningen.org)'
return
log 'Creating Leiningen project' log 'Creating Leiningen project'
exec "lein new #{projNameHyph}" exec "lein new #{projNameHyph}"
@ -391,7 +392,9 @@ init = (projName) ->
catch {message} catch {message}
logErr \ logErr \
if message.match /npm/i if message.match /type.+lein/i
'Leiningen is required (http://leiningen.org)'
else if message.match /npm/i
"npm install failed. This may be a network issue. Check #{projNameHyph}/npm-debug.log for details." "npm install failed. This may be a network issue. Check #{projNameHyph}/npm-debug.log for details."
else else
message message