Skip to content

Commit c376925

Browse files
committed
Warn and skip when Cypress config already exist
1 parent 42c772e commit c376925

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

lib/cypress-rails/init.rb

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,12 @@ class Init
2222

2323
def call(dir = Dir.pwd)
2424
config_path = File.join(dir, "cypress.config.js")
25-
config_content = determine_new_config(config_path)
26-
File.write(config_path, config_content)
27-
puts "Cypress config (re)initialized in #{config_path}"
28-
end
29-
30-
private
31-
32-
def determine_new_config(config_path)
3325
if File.exist?(config_path)
34-
merge_existing_with_defaults(config_path)
35-
else
36-
DEFAULT_CONFIG
26+
warn('Cypress config is already exist!')
27+
return
3728
end
38-
end
39-
40-
def merge_existing_with_defaults(config_path)
41-
File.read(config_path)
29+
File.write(config_path, DEFAULT_CONFIG)
30+
puts "Cypress config initialized in #{config_path}"
4231
end
4332
end
4433
end

0 commit comments

Comments
 (0)