Skip to content

Commit

Permalink
Fix bin dev scripts (#1519)
Browse files Browse the repository at this point in the history
* Fix scripts

* Ensure the scripts are executable

* Update tests
  • Loading branch information
ahangarha authored Feb 15, 2023
1 parent f84aa58 commit d0d45a1
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 16 deletions.
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

0 comments on commit d0d45a1

Please sign in to comment.