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:
parent
2ea5143529
commit
5daf7989ac
|
@ -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) ->
|
||||||
|
if os.platform() == 'win32'
|
||||||
try
|
try
|
||||||
exec executable
|
exec "where #{executable}"
|
||||||
return true
|
catch e
|
||||||
catch
|
throw new Error("type: #{executable}: not found")
|
||||||
return false
|
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
|
||||||
|
|
Loading…
Reference in New Issue