mirror of
https://github.com/cmderdev/cmder.git
synced 2025-04-18 07:32:30 +08:00
Merge pull request #60 from austinwagner/master
Remove wget dependency and verify existence of 7z.exe in build script
This commit is contained in:
commit
d3d2b80d88
@ -7,22 +7,28 @@
|
|||||||
# conemu-maximus5. Correct files are beeing picked by using labels.
|
# conemu-maximus5. Correct files are beeing picked by using labels.
|
||||||
# I will move the script for getting files by labels from php to here as soon I feel like it
|
# I will move the script for getting files by labels from php to here as soon I feel like it
|
||||||
|
|
||||||
require 'FileUtils'
|
require 'fileutils'
|
||||||
|
require 'open-uri'
|
||||||
|
require 'uri'
|
||||||
|
|
||||||
def get_file project, query
|
def get_file project, query
|
||||||
# Should be changed to integrated downloader
|
urlToFile = URI.escape('http://samuelvasko.tk/gcode/?project='+project+'&query='+query)
|
||||||
urlToFile = 'wget -q -O - "http://samuelvasko.tk/gcode/?project='+project+'&query='+query+'"'
|
open(urlToFile) do |resp|
|
||||||
urlToFile = `#{urlToFile}`
|
urlToFile = URI.escape(resp.read.split(/\r?\n/).first)
|
||||||
urlToFile = urlToFile.split("\n").first
|
end
|
||||||
|
|
||||||
extension = urlToFile.split('.').last
|
extension = urlToFile.split('.').last
|
||||||
filename = project+'.'+extension
|
filename = project+'.'+extension
|
||||||
|
|
||||||
puts "\n ------ Downloading #{project} ------- \n \n"
|
puts "\n ------ Downloading #{project} from #{urlToFile} ------- \n \n"
|
||||||
get_file = system("wget -O #{filename} #{urlToFile}")
|
begin
|
||||||
|
open(urlToFile, 'rb') do |infile|
|
||||||
unless get_file
|
open(filename, 'wb') do |outfile|
|
||||||
puts "Failied to download #{project} from #{urlToFile}"
|
outfile.write(infile.read)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
rescue IOError => error
|
||||||
|
puts error
|
||||||
FileUtils.rm(filename) if File.exists?(filename)
|
FileUtils.rm(filename) if File.exists?(filename)
|
||||||
exit(1)
|
exit(1)
|
||||||
end
|
end
|
||||||
@ -39,7 +45,17 @@ def get_file project, query
|
|||||||
FileUtils.mv(Dir.glob("#{temp_name}/*")[0], project)
|
FileUtils.mv(Dir.glob("#{temp_name}/*")[0], project)
|
||||||
FileUtils.rm_r(temp_name)
|
FileUtils.rm_r(temp_name)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def find_on_path exe
|
||||||
|
path = ENV['PATH'].split(File::PATH_SEPARATOR)
|
||||||
|
for dir in path
|
||||||
|
if File.exists?(File.join(dir, exe))
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
puts '
|
puts '
|
||||||
@ -53,6 +69,11 @@ ______ _ _ _ _ _
|
|||||||
|___/
|
|___/
|
||||||
'
|
'
|
||||||
|
|
||||||
|
unless find_on_path('7z.exe')
|
||||||
|
puts '7z.exe not found. Ensure 7-zip is installed and on the PATH.'
|
||||||
|
exit(1)
|
||||||
|
end
|
||||||
|
|
||||||
puts 'Cleanup'
|
puts 'Cleanup'
|
||||||
|
|
||||||
if Dir.exists?('vendor')
|
if Dir.exists?('vendor')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user