Skip to content
This repository was archived by the owner on Nov 5, 2024. It is now read-only.

Commit 6466775

Browse files
committed
avoid using wget
1 parent 33f9c8c commit 6466775

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

codegen/build.mk

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
define download_file
2+
URL="$(1)" SAVE_AS="$(2)" ruby scripts/download_file.rb
3+
endef
4+
15
CODEGEN_EXE = codegen/codegen$(EXE)
26

37
$(CODEGEN_EXE):
4-
wget -q https://github.com/lib-ruby-parser/nodes/releases/download/v0.52.0/codegen-$(TARGET)$(EXE) -O $(CODEGEN_EXE)
8+
$(call download_file, https://github.com/lib-ruby-parser/nodes/releases/download/v0.52.0/codegen-$(TARGET)$(EXE), $@)
59
chmod +x $(CODEGEN_EXE)
610
CLEAN += $(CODEGEN_EXE)
711

scripts/download_file.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
require 'open-uri'
2+
3+
url = ENV.fetch('URL') { abort 'URL env var must be provided.' }.strip
4+
save_as = ENV.fetch('SAVE_AS') { abort 'SAVE_AS env var must be provided' }.strip
5+
6+
File.open(save_as, 'wb') do |file|
7+
URI.open(url, 'rb') do |asset|
8+
file.write(asset.read)
9+
end
10+
end

0 commit comments

Comments
 (0)