Class: XcodeInstall::Command::InstallCLITools

Inherits:
XcodeInstall::Command show all
Defined in:
lib/xcode/install/cli.rb

Instance Method Summary collapse

Methods inherited from XcodeInstall::Command

#list

Instance Method Details

#installObject



17
18
19
20
21
22
23
24
25
# File 'lib/xcode/install/cli.rb', line 17

def install
  cli_placeholder_file = '/tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress'
  # create the placeholder file that's checked by CLI updates' .dist code in Apple's SUS catalog
  FileUtils.touch(cli_placeholder_file)
  # find the CLI Tools update
  product = `softwareupdate -l | grep "\*.*Command Line" | head -n 1 | awk -F"*" '{print $2}' | sed -e 's/^ *//' | tr -d '\n'`
  `softwareupdate -i "#{product}" -v`
  FileUtils.rm(cli_placeholder_file)
end

#installed?Boolean

Returns:

  • (Boolean)


12
13
14
15
# File 'lib/xcode/install/cli.rb', line 12

def installed?
  `xcode-select -p`
  $?.success?
end

#runObject



7
8
9
10
# File 'lib/xcode/install/cli.rb', line 7

def run
  fail Informative, 'Xcode CLI Tools are already installed.' if installed?
  install
end