Skip to content

Instantly share code, notes, and snippets.

@tmspzz
Created July 11, 2017 16:06
Show Gist options
  • Save tmspzz/318d773a127da64300443ef149fa1229 to your computer and use it in GitHub Desktop.
Save tmspzz/318d773a127da64300443ef149fa1229 to your computer and use it in GitHub Desktop.
Download HLint via a Rake task
# @example
#
# rake hlint:install[2.0.9]
namespace :hlint do
desc "Download and install hlint"
task :install, :version do |task, args|
REPO = "https://github.com/ndmitchell/hlint"
VERSION = args[:version].to_s
ASSET = "hlint-#{VERSION}-x86_64-linux.tar.gz"
URL = "#{REPO}/releases/download/v#{VERSION}/#{ASSET}"
DESTINATION_BASE = File.expand_path(File.join(File.dirname(__FILE__), 'bin'))
DESTINATION_TMP = File.join("#{DESTINATION_BASE}", 'tmp')
puts "Downloading hlint@v#{VERSION}"
sh [
"mkdir -p #{DESTINATION_TMP}",
"curl -s -L #{URL} -o #{ASSET}",
"tar -xf #{ASSET} -C #{DESTINATION_TMP}",
"cp #{DESTINATION_TMP}/hlint-#{VERSION}/hlint #{File.expand_path("~/.local/bin")}",
"cp -R #{DESTINATION_TMP}/hlint-#{VERSION}/data #{File.expand_path("~/.local/bin")}",
"rm -r #{DESTINATION_BASE}/",
"rm #{ASSET}"
].join(" && ")
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment