159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
# File 'lib/zui/dist_config.rb', line 159
def load(project:, platform: Platform.current)
project = File.expand_path(project)
path = File.join(project, CONFIG_FILE)
raise ArgumentError, "#{CONFIG_FILE} not found in project root" unless File.file?(path)
raise ArgumentError, "#{CONFIG_FILE} is too large" if File.size(path) > 131_072
value = Module.new.module_eval(File.read(path), path, 1)
unless value.is_a?(Config)
raise ArgumentError, "#{CONFIG_FILE} must return Zui::Dist.configure do ... end"
end
value.validate!(project:, platform: platform.assert_supported!)
rescue SyntaxError => error
raise ArgumentError, "invalid #{CONFIG_FILE}: #{error.message.lines.first.to_s.strip}"
rescue ScriptError => error
raise ArgumentError, "#{CONFIG_FILE} failed: #{error.class}: #{error.message}"
rescue ArgumentError
raise
rescue StandardError => error
raise ArgumentError, "#{CONFIG_FILE} failed: #{error.class}: #{error.message}"
end
|