Skip to content

Commit d47fa8d

Browse files
committed
remove front matter from user files
1 parent a58df1a commit d47fa8d

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/bashly/extensions/string.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,8 @@ def lint
2727
gsub(/\s+\n/m, "\n\n").lines.reject { |l| l =~ /^\s*##/ }.join ""
2828
end
2929

30+
def remove_front_matter
31+
split(/^---\s*/).last
32+
end
33+
3034
end

lib/bashly/script/command.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def load_user_file(file, placeholder: true)
154154
default_content = placeholder ? "echo \"error: cannot load file\"" : ''
155155

156156
content = if File.exist? path
157-
File.read path
157+
File.read(path).remove_front_matter
158158
else
159159
default_content
160160
end

0 commit comments

Comments
 (0)