Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Prevent a couple of known Heroku validations from derailing the user.…

… Closes GH-447
  • Loading branch information...
commit cf1b6064ec55faec5aca5b3603264c133b3b68d2 1 parent 22a0be0
Philip Arndt parndt authored

Showing 1 changed file with 24 additions and 1 deletion. Show diff stats Hide diff stats

  1. +24 1 bin/refinerycms
25 bin/refinerycms
@@ -180,12 +180,35 @@ module Refinery
180 180 puts "Please choose another name for your new project."
181 181 puts "\n"
182 182 exit(1)
183   - elsif @app_path.directory? and @options[:force] == false and @options[:update] == false
  183 + elsif @app_path.directory? && !@options[:force] && !@options[:update]
184 184 puts "\nThe directory '#{@app_path}' that you specified already exists."
185 185 puts "Use --force to overwrite an existing directory."
186 186 puts "Use --update to replace any Refinery CMS files in an existing installation."
187 187 puts "\n"
188 188 exit(1)
  189 + elsif @options[:heroku]
  190 + if @options[:heroku].to_s.include?('_') or @options[:heroku].to_s.length > 30
  191 + message = ["\nThe application name '#{@options[:heroku]}' that you specified is invalid for Heroku."]
  192 + suggested_name = @options[:heroku].to_s
  193 + if suggested_name.include?('_')
  194 + message << "This is because it contains underscores which Heroku does not allow."
  195 + suggested_name.gsub!(/_/, '-')
  196 + end
  197 + if suggested_name.length > 30
  198 + message << "This is#{" also" unless suggested_name.nil?} because it is longer than 30 characters."
  199 + suggested_name = suggested_name[0..29]
  200 + end
  201 +
  202 + if @options[:force] or @options[:confirm]
  203 + @options[:heroku] = suggested_name
  204 + else
  205 + message << "Please choose another name like '#{suggested_name}'"
  206 + message << "Or use --confirm to automatically use '#{suggested_name}'"
  207 + message << "\n"
  208 + puts message.join("\n")
  209 + exit(1)
  210 + end
  211 + end
189 212 elsif @app_path.join('.git').directory? && @options[:update] && !@options[:confirm]
190 213 git_status = run_command('git status --porcelain', :puts => false)
191 214 if git_status.to_s.strip.length > 0

0 comments on commit cf1b606

Please sign in to comment.
Something went wrong with that request. Please try again.