From 6bc1bda9e90eca24a4305de0d4e13e22ae107504 Mon Sep 17 00:00:00 2001 From: Frank Taillandier Date: Wed, 31 Oct 2018 22:52:05 +0100 Subject: [PATCH] Revert "fix: display a warning when file exists (#81)" This reverts commit 94a30257f61ad53c481d9dda9a05a50e8837d9a2. --- lib/jekyll-compose/file_creator.rb | 2 +- spec/draft_spec.rb | 7 ++++--- spec/page_spec.rb | 7 ++++--- spec/post_spec.rb | 7 ++++--- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/jekyll-compose/file_creator.rb b/lib/jekyll-compose/file_creator.rb index 17a7e0e..2a33789 100644 --- a/lib/jekyll-compose/file_creator.rb +++ b/lib/jekyll-compose/file_creator.rb @@ -25,7 +25,7 @@ def file_path private def validate_should_write! - return Jekyll.logger.warn "A #{file.resource_type} already exists at #{file_path}".yellow if File.exist?(file_path) && !force + raise ArgumentError, "A #{file.resource_type} already exists at #{file_path}" if File.exist?(file_path) && !force end def ensure_directory_exists diff --git a/spec/draft_spec.rb b/spec/draft_spec.rb index f5759ba..908c785 100644 --- a/spec/draft_spec.rb +++ b/spec/draft_spec.rb @@ -63,9 +63,10 @@ FileUtils.touch path end - it "displays a warning and abort" do - output = capture_stdout { described_class.process(args) } - expect(output).to include("A draft already exists at _drafts/an-existing-draft.md".yellow) + it "raises an error" do + expect(lambda { + capture_stdout { described_class.process(args) } + }).to raise_error("A draft already exists at _drafts/an-existing-draft.md") end it "overwrites if --force is given" do diff --git a/spec/page_spec.rb b/spec/page_spec.rb index a631886..fabb4bd 100644 --- a/spec/page_spec.rb +++ b/spec/page_spec.rb @@ -52,9 +52,10 @@ FileUtils.touch path end - it "displays a warning" do - output = capture_stdout { described_class.process(args) } - expect(output).to include("A page already exists at #{filename}".yellow) + it "raises an error" do + expect(lambda { + capture_stdout { described_class.process(args) } + }).to raise_error("A page already exists at #{filename}") end it "overwrites if --force is given" do diff --git a/spec/post_spec.rb b/spec/post_spec.rb index f947af0..7f5d4fa 100644 --- a/spec/post_spec.rb +++ b/spec/post_spec.rb @@ -74,9 +74,10 @@ FileUtils.touch path end - it "displays a warning" do - output = capture_stdout { described_class.process(args) } - expect(output).to include("A post already exists at _posts/#{filename}".yellow) + it "raises an error" do + expect(lambda { + capture_stdout { described_class.process(args) } + }).to raise_error("A post already exists at _posts/#{filename}") end it "overwrites if --force is given" do