display an error in case OSX specific command is executed on other OS
This commit is contained in:
parent
006bc7d781
commit
ab7f00031d
|
@ -55,6 +55,12 @@ ensureExecutableAvailable = (executable) ->
|
|||
else
|
||||
exec "type #{executable}"
|
||||
|
||||
ensureOSX = (cb) ->
|
||||
if os.platform() == 'darwin'
|
||||
cb()
|
||||
else
|
||||
logErr 'This command is only available on OSX'
|
||||
|
||||
readFile = (path) ->
|
||||
fs.readFileSync path, encoding: 'ascii'
|
||||
|
||||
|
@ -115,7 +121,7 @@ ensureFreePort = (cb) ->
|
|||
|
||||
ensureXcode = (cb) ->
|
||||
try
|
||||
exec 'type xcodebuild'
|
||||
ensureExecutableAvailable 'xcodebuild'
|
||||
config = readConfig()
|
||||
unless config.device?
|
||||
config.device = getUuidForDevice 'iPhone 6'
|
||||
|
@ -570,6 +576,7 @@ cli.command 'init <name>'
|
|||
cli.command 'launch'
|
||||
.description 'compile project and run in iOS simulator'
|
||||
.action ->
|
||||
ensureOSX ->
|
||||
ensureXcode ->
|
||||
ensureFreePort -> launch readConfig()
|
||||
|
||||
|
@ -581,6 +588,7 @@ cli.command 'upgrade'
|
|||
cli.command 'listdevices'
|
||||
.description 'list available simulator devices by index'
|
||||
.action ->
|
||||
ensureOSX ->
|
||||
ensureXcode ->
|
||||
console.log (getDeviceList()
|
||||
.map (line, i) -> "#{i}\t#{line.replace /\[.+\]/, ''}"
|
||||
|
@ -589,6 +597,7 @@ cli.command 'listdevices'
|
|||
cli.command 'setdevice <index>'
|
||||
.description 'choose simulator device by index'
|
||||
.action (index) ->
|
||||
ensureOSX ->
|
||||
ensureXcode ->
|
||||
unless device = getDeviceList()[parseInt index, 10]
|
||||
logErr 'Invalid device index. Run re-natal listdevices for valid indexes.'
|
||||
|
@ -600,6 +609,7 @@ cli.command 'setdevice <index>'
|
|||
cli.command 'xcode'
|
||||
.description 'open Xcode project'
|
||||
.action ->
|
||||
ensureOSX ->
|
||||
ensureXcode ->
|
||||
openXcode readConfig().name
|
||||
|
||||
|
|
Loading…
Reference in New Issue