class XcodeInstall::Command::InstallCLITools

Public Instance Methods

install() click to toggle source
# File lib/xcode/install/cli.rb, line 19
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 --verbose -i "#{product}"`
  FileUtils.rm(cli_placeholder_file)
end
installed?() click to toggle source
# File lib/xcode/install/cli.rb, line 15
def installed?
  File.exist?('/Library/Developer/CommandLineTools/usr/lib/libxcrun.dylib')
end
run() click to toggle source
# File lib/xcode/install/cli.rb, line 7
def run
  if installed?
    print 'Xcode CLI Tools are already installed.'
    exit(0)
  end
  install
end