Skip to content

Commit

Permalink
Add overmind as the first option to run
Browse files Browse the repository at this point in the history
Changes:
- Use Ruby instead of bash script for cross-platform use
- Prefer Overmind over Foreman
- Show relevant messages if both Overmind and Foreman not installed
  and if Procfile missing
  • Loading branch information
ahangarha committed Dec 30, 2022
1 parent f20fa61 commit 16cdead
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 14 deletions.
37 changes: 30 additions & 7 deletions lib/generators/react_on_rails/bin/dev
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@
#!/usr/bin/env bash
#!/usr/bin/env ruby
# frozen_string_literal: true

if ! command -v foreman &> /dev/null
then
echo "Installing foreman…"
gem install foreman && echo "Foreman Installed."
fi
def installed?(process)
IO.popen "#{process} -v"
rescue Errno::ENOENT
false
end

foreman start -f Procfile.dev
def run(process)
argv = ARGV.join(" ")
puts "Using #{process}"
exec "#{process} start -f Procfile.dev", argv
rescue Errno::ENOENT
puts <<~MSG
ERROR:
Please ensure `Procfile.dev` exist in your project!
MSG
exit!
end

if installed? "overmind"
run "overmind"
elsif installed? "foreman"
run "foreman"
else
puts <<~MSG
NOTICE:
For this script to run, you need either 'overmind' or 'foreman' installed on your machine. Please try this script after installing one of them.
MSG
exit!
end
37 changes: 30 additions & 7 deletions lib/generators/react_on_rails/bin/dev-static
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@
#!/usr/bin/env bash
#!/usr/bin/env ruby
# frozen_string_literal: true

if ! command -v foreman &> /dev/null
then
echo "Installing foreman…"
gem install foreman && echo "Foreman Installed."
fi
def installed?(process)
IO.popen "#{process} -v"
rescue Errno::ENOENT
false
end

foreman start -f Procfile.dev-static
def run(process)
argv = ARGV.join(" ")
puts "Using #{process}"
exec "#{process} start -f Procfile.dev-static", argv
rescue Errno::ENOENT
puts <<~MSG
ERROR:
Please ensure `Procfile.dev-static` exist in your project!
MSG
exit!
end

if installed? "overmind"
run "overmind"
elsif installed? "foreman"
run "foreman"
else
puts <<~MSG
NOTICE:
For this script to run, you need either 'overmind' or 'foreman' installed on your machine. Please try this script after installing one of them.
MSG
exit!
end

0 comments on commit 16cdead

Please sign in to comment.