Skip to content

Commit 736f60d

Browse files
committed
let shakapacker handle package manager for us
1 parent 243eb9f commit 736f60d

File tree

2 files changed

+1
-33
lines changed

2 files changed

+1
-33
lines changed

lib/generators/react_on_rails/install_generator.rb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,7 @@ def invoke_generators
6262
# js(.coffee) are not checked by this method, but instead produce warning messages
6363
# and allow the build to continue
6464
def installation_prerequisites_met?
65-
!(missing_node? || missing_npm? || ReactOnRails::GitUtils.uncommitted_changes?(GeneratorMessages))
66-
end
67-
68-
def missing_npm?
69-
return false unless ReactOnRails::Utils.running_on_windows? ? `where npm`.blank? : `which npm`.blank?
70-
71-
error = "npm is required. Please install it before continuing. https://docs.npmjs.com/downloading-and-installing-node-js-and-npm"
72-
GeneratorMessages.add_error(error)
73-
true
65+
!(missing_node? || ReactOnRails::GitUtils.uncommitted_changes?(GeneratorMessages))
7466
end
7567

7668
def missing_node?

spec/react_on_rails/generators/install_generator_spec.rb

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,6 @@
7575
allow(install_generator).to receive(:`).with("which node").and_return("/path/to/bin")
7676
expect(install_generator.send(:missing_node?)).to be false
7777
end
78-
79-
specify "when npm is exist" do
80-
stub_const("RUBY_PLATFORM", "linux")
81-
allow(install_generator).to receive(:`).with("which npm").and_return("/path/to/bin")
82-
expect(install_generator.send(:missing_npm?)).to be false
83-
end
8478
end
8579

8680
context "when detecting missing bin-files on *nix" do
@@ -91,12 +85,6 @@
9185
allow(install_generator).to receive(:`).with("which node").and_return("")
9286
expect(install_generator.send(:missing_node?)).to be true
9387
end
94-
95-
specify "when npm is missing" do
96-
stub_const("RUBY_PLATFORM", "linux")
97-
allow(install_generator).to receive(:`).with("which npm").and_return("")
98-
expect(install_generator.send(:missing_npm?)).to be true
99-
end
10088
end
10189

10290
context "when detecting existing bin-files on windows" do
@@ -107,12 +95,6 @@
10795
allow(install_generator).to receive(:`).with("where node").and_return("/path/to/bin")
10896
expect(install_generator.send(:missing_node?)).to be false
10997
end
110-
111-
specify "when npm is exist" do
112-
stub_const("RUBY_PLATFORM", "mswin")
113-
allow(install_generator).to receive(:`).with("where npm").and_return("/path/to/bin")
114-
expect(install_generator.send(:missing_npm?)).to be false
115-
end
11698
end
11799

118100
context "when detecting missing bin-files on windows" do
@@ -123,12 +105,6 @@
123105
allow(install_generator).to receive(:`).with("where node").and_return("")
124106
expect(install_generator.send(:missing_node?)).to be true
125107
end
126-
127-
specify "when npm is missing" do
128-
stub_const("RUBY_PLATFORM", "mswin")
129-
allow(install_generator).to receive(:`).with("where npm").and_return("")
130-
expect(install_generator.send(:missing_npm?)).to be true
131-
end
132108
end
133109

134110
context "when detecting Shakapacker installation" do

0 commit comments

Comments
 (0)