Commit bacf7fd78ad4eee74abb17eefc5337dc704640fb
1 parent
6033e94d87
Boxen.run -> Boxen::CLI.run
Showing 1 changed file with 3 additions and 1 deletions Inline Diff
script/boxen
| #!/usr/bin/ruby | 1 | 1 | #!/usr/bin/ruby | |
| # Run Boxen. | 2 | 2 | # Run Boxen. | |
| 3 | 3 | |||
| require "pathname" | 4 | 4 | require "pathname" | |
| 5 | 5 | |||
| if ENV["USER"] == "root" | 6 | 6 | if ENV["USER"] == "root" | |
| abort "Run this as a normal user, I'll sudo if I need to." | 7 | 7 | abort "Run this as a normal user, I'll sudo if I need to." | |
| end | 8 | 8 | end | |
| 9 | 9 | |||
| # Make sure only one boxen process runs at a time. | 10 | 10 | # Make sure only one boxen process runs at a time. | |
| 11 | 11 | |||
| myself = File.new __FILE__ | 12 | 12 | myself = File.new __FILE__ | |
| 13 | 13 | |||
| unless myself.flock File::LOCK_EX | File::LOCK_NB | 14 | 14 | unless myself.flock File::LOCK_EX | File::LOCK_NB | |
| abort "You're already running a boxen process! Know a patience." | 15 | 15 | abort "You're already running a boxen process! Know a patience." | |
| end | 16 | 16 | end | |
| 17 | 17 | |||
| # Yeah yeah, I like to be explicit. | 18 | 18 | # Yeah yeah, I like to be explicit. | |
| 19 | 19 | |||
| at_exit { myself.flock File::LOCK_UN } | 20 | 20 | at_exit { myself.flock File::LOCK_UN } | |
| 21 | 21 | |||
| # Put us where we belong, in the root dir of our boxen repo. | 22 | 22 | # Put us where we belong, in the root dir of our boxen repo. | |
| 23 | 23 | |||
| Dir.chdir Pathname.new(__FILE__).realpath + "../.." | 24 | 24 | Dir.chdir Pathname.new(__FILE__).realpath + "../.." | |
| 25 | 25 | |||
| # FIX: temporarily set BOXEN_HOME to `./tmp/home` during porting. | 26 | 26 | # FIX: temporarily set BOXEN_HOME to `./tmp/home` during porting. | |
| 27 | 27 | |||
| ENV["BOXEN_HOME"] = File.expand_path("tmp/home") | 28 | 28 | ENV["BOXEN_HOME"] = File.expand_path("tmp/home") | |
| 29 | 29 | |||
| # Auto-update code. This is done as early as possible so that changes | 30 | 30 | # Auto-update code. This is done as early as possible so that changes | |
| # to boxen support code or dependencies can be grabbed. | 31 | 31 | # to boxen support code or dependencies can be grabbed. | |
| 32 | 32 | |||
| unless ENV["BOXEN_NO_PULL"] || ARGV.include?("--no-pull") | 33 | 33 | unless ENV["BOXEN_NO_PULL"] || ARGV.include?("--no-pull") | |
| if system("which git > /dev/null") && File.directory?(".git") | 34 | 34 | if system("which git > /dev/null") && File.directory?(".git") | |
| clean = `git status --porcelain`.empty? | 35 | 35 | clean = `git status --porcelain`.empty? | |
| master = `git symbolic-ref HEAD`.chomp == "refs/heads/master" | 36 | 36 | master = `git symbolic-ref HEAD`.chomp == "refs/heads/master" | |
| no_new_commits = system('git diff --exit-code --quiet origin/master master') | 37 | 37 | no_new_commits = system('git diff --exit-code --quiet origin/master master') | |
| 38 | 38 | |||
| if clean && master && no_new_commits | 39 | 39 | if clean && master && no_new_commits | |
| quietly = "> /dev/null 2>&1" | 40 | 40 | quietly = "> /dev/null 2>&1" | |
| fetch = "(git fetch origin #{quietly})" | 41 | 41 | fetch = "(git fetch origin #{quietly})" | |
| reset = "(git reset --hard origin/master #{quietly})" | 42 | 42 | reset = "(git reset --hard origin/master #{quietly})" | |
| reclean = "(git clean -df #{quietly})" | 43 | 43 | reclean = "(git clean -df #{quietly})" | |
| 44 | 44 | |||
| unless system "#{fetch} && #{reset} && #{reclean}" | 45 | 45 | unless system "#{fetch} && #{reset} && #{reclean}" |