lib/pgsync/init.rb in pgsync-0.5.2 vs lib/pgsync/init.rb in pgsync-0.5.3

- old
+ new

@@ -10,33 +10,37 @@ if File.exist?(file) raise Error, "#{file} exists." else exclude = - if rails_app? + if rails? <<~EOS exclude: - schema_migrations - ar_internal_metadata EOS else <<~EOS # exclude: - # - schema_migrations - # - ar_internal_metadata + # - table1 + # - table2 EOS end # create file contents = File.read(__dir__ + "/../../config.yml") + contents.sub!("$(some_command)", "$(heroku config:get DATABASE_URL)") if heroku? File.write(file, contents % {exclude: exclude}) log "#{file} created. Add your database credentials." end end - # TODO maybe check parent directories - def rails_app? + def heroku? + `git remote -v 2>&1`.include?("git.heroku.com") rescue false + end + + def rails? File.exist?("bin/rails") end end end