Skip to content

Commit a654720

Browse files
authored
Merge pull request #215 from DannyBen/refactor/load_user_file
Reduce cognitive complexity in `Command#load_user_file`
2 parents 3ced4f2 + 32916e6 commit a654720

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/bashly/script/command.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,13 @@ def full_name
9494
# If the file is not found, returns a string with a hint.
9595
def load_user_file(file, placeholder: true)
9696
path = "#{Settings.source_dir}/#{file}"
97-
default_content = placeholder ? "echo \"error: cannot load file\"" : ''
9897

9998
content = if File.exist? path
10099
File.read(path).remove_front_matter
101-
else
102-
default_content
100+
elsif placeholder
101+
%q[echo "error: cannot load file"]
102+
else
103+
''
103104
end
104105

105106
Bashly.production? ? content : "#{view_marker path}\n#{content}"

0 commit comments

Comments
 (0)