Sha256: f5b63733a3d60640d1c580c7c27351ec30c0e3af09f059e85410b88e42f2db23
Contents?: true
Size: 790 Bytes
Versions: 4
Compression:
Stored size: 790 Bytes
Contents
module CypressRails class Init DEFAULT_CONFIG = { "screenshotsFolder" => "tmp/cypress_screenshots", "videosFolder" => "tmp/cypress_videos", "trashAssetsBeforeRuns" => false, } def call(dir = Dir.pwd) config_path = File.join(dir, "cypress.json") json = JSON.pretty_generate(determine_new_config(config_path)) File.write(config_path, json) puts "Cypress config (re)initialized in #{config_path}" end private def determine_new_config(config_path) if File.exist?(config_path) merge_existing_with_defaults(config_path) else DEFAULT_CONFIG end end def merge_existing_with_defaults(json_path) Hash[JSON.parse(File.read(json_path)).merge(DEFAULT_CONFIG).sort] end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
cypress-rails-0.0.4 | lib/cypress-rails/init.rb |
cypress-rails-0.0.3 | lib/cypress-rails/init.rb |
cypress-rails-0.0.2 | lib/cypress-rails/init.rb |
cypress-rails-0.0.1 | lib/cypress-rails/init.rb |