diff --git a/lib/erb_lint/cli.rb b/lib/erb_lint/cli.rb index 21cc4477..6cb03395 100644 --- a/lib/erb_lint/cli.rb +++ b/lib/erb_lint/cli.rb @@ -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 diff --git a/spec/erb_lint/cli_spec.rb b/spec/erb_lint/cli_spec.rb index edbc6026..50da7582 100644 --- a/spec/erb_lint/cli_spec.rb +++ b/spec/erb_lint/cli_spec.rb @@ -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 diff --git a/spec/fixtures/invalid-config.yml b/spec/fixtures/invalid-config.yml new file mode 100644 index 00000000..079b5796 --- /dev/null +++ b/spec/fixtures/invalid-config.yml @@ -0,0 +1 @@ +]