Skip to content

Commit d576820

Browse files
committed
Add a script/bootstrap
1 parent 38f00e1 commit d576820

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

script/bootstrap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
exec $0.rb "$@"

script/bootstrap.rb

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env ruby
2+
#/ Usage: script/bootstrap [<options>]
3+
#/ Bootstraps the gem environment.
4+
#/
5+
#/ Options are passed through to the bundle-install command. In most cases you
6+
#/ won't need these. They're used primarily in production environments.
7+
#
8+
# =============================================================================
9+
# Uses bundler to install all gems specified in the Gemfile.
10+
#
11+
# show usage message with --help
12+
if ARGV.include?('--help')
13+
system "grep '^#/' <'#{__FILE__}' |cut -c4-"
14+
exit 2
15+
end
16+
17+
# go into the project root because it makes everything easier
18+
root = File.expand_path('../..', __FILE__)
19+
Dir.chdir(root)
20+
21+
# bring in rubygems and make sure bundler is installed.
22+
require 'rubygems'
23+
begin
24+
require 'bundler'
25+
rescue LoadError => boom
26+
warn "Bundler not found. Install it with `gem install bundler' and try again."
27+
exit 1
28+
end
29+
30+
# run bundle-install to install any missing gems
31+
argv = ['--no-color', 'install']
32+
argv += ARGV
33+
system("bundle", *argv) || begin
34+
if $?.exitstatus == 127
35+
warn "bundle executable not found. Ensure bundler is installed (`gem " +
36+
"install bundler`) and that the gem bin path is in your PATH"
37+
end
38+
exit($?.exitstatus)
39+
end
40+

0 commit comments

Comments
 (0)