~singpolyma/dhall-ruby

513a86423369e813dbf99bf3c90afc6f8cfb089f — Stephen Paul Weber 3 years ago e556078
Environment variable failure can fallback
1 files changed, 10 insertions(+), 6 deletions(-)

M lib/dhall/ast.rb
M lib/dhall/ast.rb => lib/dhall/ast.rb +10 -6
@@ 1075,12 1075,16 @@ module Dhall
			end

			def resolve(resolver)
				val = ENV.fetch(@var)
				if val =~ /\Ahttps?:\/\//
					URI.from_uri(URI(value))
				else
					Path.from_string(val)
				end.resolve(resolver)
				Promise.resolve(nil).then do
					val = ENV.fetch(@var) do
						raise ImportFailedException, "No ENV #{@var}"
					end
					if val =~ /\Ahttps?:\/\//
						URI.from_uri(URI(value))
					else
						Path.from_string(val)
					end.resolve(resolver)
				end
			end

			def as_json