Skip to content
This repository has been archived by the owner on Jan 28, 2022. It is now read-only.

Commit

Permalink
FEATURE: create config/dev.yml file automatically if not exists.
Browse files Browse the repository at this point in the history
  • Loading branch information
vinothkannans committed Apr 9, 2021
1 parent 6a121c3 commit 2a1de36
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/discourse_dev/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ class Config
attr_reader :config, :default_config

def initialize
@default_config = YAML.load_file(File.join(File.expand_path(__dir__), "config.yml"))
default_file_path = File.join(File.expand_path(__dir__), "config.yml")
file_path = File.join(Rails.root, "config", "dev.yml")
@default_config = YAML.load_file(default_file_path)

if File.exists?(file_path)
@config = YAML.load_file(file_path)
else
puts "I did no detect a custom `config/dev.yml` file, creating one for you where you can amend defaults."
FileUtils.cp(default_file_path, file_path)
@config = {}
end
end
Expand Down
3 changes: 3 additions & 0 deletions lib/discourse_dev/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ class User < Record

def initialize(count = DEFAULT_COUNT)
super(::User, count)

# Using the stock avatar images from https://tinyfac.es
# Tiny Faces is a free crowd-sourced avatar gallery
@images = Dir[File.join(__dir__, '..', '..', 'avatars', '*.*')]
end

Expand Down

0 comments on commit 2a1de36

Please sign in to comment.