Skip to content

Commit

Permalink
Switch to the simpler generate method and error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
waferbaby committed Jan 28, 2024
1 parent 155b137 commit 1bba030
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions bin/dimples
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,23 @@
$LOAD_PATH.unshift(File.join(__dir__, '..', 'lib'))

require 'dimples'

source_path = ARGV[0]
output_path = ARGV[1]
require 'yaml'

config_path = File.join(Dir.pwd, 'config.yml')

config = {}

if File.exist?(config_path)
begin
config = YAML.safe_load_file(config_path, symbolize_names: true)
config = begin
YAML.safe_load_file(config_path, symbolize_names: true)
rescue YAML::Error
puts 'Error reading config file - reverting to defaults'
puts 'Failed to parse config - using defaults'
ensure
{}
end
end

begin
Dimples::Site.generate(source_path, output_path, config)
rescue Dimples::Error => e
puts "Error: #{e.message}"
Dimples::Site.generate(config)
rescue StandardError => e
puts "Error generating site: #{e}"
end

0 comments on commit 1bba030

Please sign in to comment.