File tree Expand file tree Collapse file tree 4 files changed +10
-13
lines changed
Expand file tree Collapse file tree 4 files changed +10
-13
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ def file_path
2525 private
2626
2727 def validate_should_write!
28- raise ArgumentError , "A #{ file . resource_type } already exists at #{ file_path } " if File . exist? ( file_path ) && !force
28+ return Jekyll . logger . warn "A #{ file . resource_type } already exists at #{ file_path } " . yellow if File . exist? ( file_path ) && !force
2929 end
3030
3131 def ensure_directory_exists
Original file line number Diff line number Diff line change 6363 FileUtils . touch path
6464 end
6565
66- it "raises an error" do
67- expect ( lambda {
68- capture_stdout { described_class . process ( args ) }
69- } ) . to raise_error ( "A draft already exists at _drafts/an-existing-draft.md" )
66+ it "displays a warning and abort" do
67+ output = capture_stdout { described_class . process ( args ) }
68+ expect ( output ) . to include ( "A draft already exists at _drafts/an-existing-draft.md" . yellow )
7069 end
7170
7271 it "overwrites if --force is given" do
Original file line number Diff line number Diff line change 5252 FileUtils . touch path
5353 end
5454
55- it "raises an error" do
56- expect ( lambda {
57- capture_stdout { described_class . process ( args ) }
58- } ) . to raise_error ( "A page already exists at #{ filename } " )
55+ it "displays a warning" do
56+ output = capture_stdout { described_class . process ( args ) }
57+ expect ( output ) . to include ( "A page already exists at #{ filename } " . yellow )
5958 end
6059
6160 it "overwrites if --force is given" do
Original file line number Diff line number Diff line change 7474 FileUtils . touch path
7575 end
7676
77- it "raises an error" do
78- expect ( lambda {
79- capture_stdout { described_class . process ( args ) }
80- } ) . to raise_error ( "A post already exists at _posts/#{ filename } " )
77+ it "displays a warning" do
78+ output = capture_stdout { described_class . process ( args ) }
79+ expect ( output ) . to include ( "A post already exists at _posts/#{ filename } " . yellow )
8180 end
8281
8382 it "overwrites if --force is given" do
You can’t perform that action at this time.
0 commit comments