Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Guard against missing config and surface config parsing errors #305

Merged
merged 1 commit into from
Feb 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/erb_lint/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def load_config
rescue Psych::SyntaxError => e
failure!("error parsing config: #{e.message}")
ensure
@config.merge!(runner_config_override)
@config&.merge!(runner_config_override)
end

def file_loader
Expand Down
11 changes: 11 additions & 0 deletions spec/erb_lint/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,17 @@ def run(processed_source)
expect(subject).to(be(true))
end
end

context "when file has a syntax error" do
before { FakeFS::FileSystem.clone(File.join(__dir__, "../fixtures"), "/") }

let(:args) { ["--config", "invalid-config.yml", "--lint-all"] }

it { expect { subject }.to(output(/error parsing config:/).to_stderr) }
it "is not successful" do
expect(subject).to(be(false))
end
end
end

context "with custom --cache-dir" do
Expand Down
1 change: 1 addition & 0 deletions spec/fixtures/invalid-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
]