Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bin dev scripts #1519

Merged
merged 3 commits into from
Feb 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions lib/generators/react_on_rails/bin/dev
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ rescue Errno::ENOENT
end

def run(process)
args = [*ARGV]
args.shift
puts "Using #{process}"
exec "#{process} start -f Procfile.dev", args.join(" ")
system "#{process} start -f Procfile.dev"
rescue Errno::ENOENT
warn <<~MSG
ERROR:
Expand Down
5 changes: 1 addition & 4 deletions lib/generators/react_on_rails/bin/dev-static
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ rescue Errno::ENOENT
end

def run(process)
args = [*ARGV]
args.shift
puts "Using #{process}"
exec "#{process} start -f Procfile.dev-static", args.join(" ")
system "#{process} start -f Procfile.dev-static"
rescue Errno::ENOENT
warn <<~MSG
ERROR:
Expand Down
9 changes: 9 additions & 0 deletions lib/generators/react_on_rails/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ def missing_node?

def add_bin_scripts
directory "#{__dir__}/bin", "bin"

# Make these and only these files executable
files_to_copy = []
Dir.chdir("#{__dir__}/bin") do
files_to_copy.concat(Dir.glob("*"))
end
files_to_become_excutable = files_to_copy.map { |filename| "bin/#{filename}" }

File.chmod(0o755, *files_to_become_excutable)
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/react_on_rails/binstubs/dev_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
it "with Overmind installed, uses Overmind" do
allow(IO).to receive(:popen).with("overmind -v").and_return("Some truthy result")

expect_any_instance_of(Kernel).to receive(:exec).with("overmind start -f Procfile.dev", "")
expect_any_instance_of(Kernel).to receive(:system).with("overmind start -f Procfile.dev")

load script_path
end
Expand All @@ -28,7 +28,7 @@
allow(IO).to receive(:popen).with("overmind -v").and_raise(Errno::ENOENT)
allow(IO).to receive(:popen).with("foreman -v").and_return("Some truthy result")

expect_any_instance_of(Kernel).to receive(:exec).with("foreman start -f Procfile.dev", "")
expect_any_instance_of(Kernel).to receive(:system).with("foreman start -f Procfile.dev")

load script_path
end
Expand All @@ -50,8 +50,8 @@
allow(IO).to receive(:popen).with("overmind -v").and_return("Some truthy result")

allow_any_instance_of(Kernel)
.to receive(:exec)
.with("overmind start -f Procfile.dev", "")
.to receive(:system)
.with("overmind start -f Procfile.dev")
.and_raise(Errno::ENOENT)
allow_any_instance_of(Kernel).to receive(:exit!)

Expand Down
8 changes: 4 additions & 4 deletions spec/react_on_rails/binstubs/dev_static_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
it "with Overmind installed, uses Overmind" do
allow(IO).to receive(:popen).with("overmind -v").and_return("Some truthy result")

expect_any_instance_of(Kernel).to receive(:exec).with("overmind start -f Procfile.dev-static", "")
expect_any_instance_of(Kernel).to receive(:system).with("overmind start -f Procfile.dev-static")

load script_path
end
Expand All @@ -28,7 +28,7 @@
allow(IO).to receive(:popen).with("overmind -v").and_raise(Errno::ENOENT)
allow(IO).to receive(:popen).with("foreman -v").and_return("Some truthy result")

expect_any_instance_of(Kernel).to receive(:exec).with("foreman start -f Procfile.dev-static", "")
expect_any_instance_of(Kernel).to receive(:system).with("foreman start -f Procfile.dev-static")

load script_path
end
Expand All @@ -50,8 +50,8 @@
allow(IO).to receive(:popen).with("overmind -v").and_return("Some truthy result")

allow_any_instance_of(Kernel)
.to receive(:exec)
.with("overmind start -f Procfile.dev-static", "")
.to receive(:system)
.with("overmind start -f Procfile.dev-static")
.and_raise(Errno::ENOENT)
allow_any_instance_of(Kernel).to receive(:exit!)

Expand Down