Skip to content

Commit

Permalink
Revert "fix: display a warning when file exists (#81)"
Browse files Browse the repository at this point in the history
This reverts commit 94a3025.
  • Loading branch information
DirtyF committed Oct 31, 2018
1 parent cb9a525 commit 6bc1bda
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/jekyll-compose/file_creator.rb
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions spec/draft_spec.rb
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions spec/page_spec.rb
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions spec/post_spec.rb
Expand Up @@ -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
Expand Down

0 comments on commit 6bc1bda

Please sign in to comment.