Skip to content

Commit e131192

Browse files
committed
generator: switch install prerequisite from yarn to npm and update specs
1 parent f4adcd9 commit e131192

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

lib/generators/react_on_rails/install_generator.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ def invoke_generators
6161
# js(.coffee) are not checked by this method, but instead produce warning messages
6262
# and allow the build to continue
6363
def installation_prerequisites_met?
64-
!(missing_node? || missing_yarn? || ReactOnRails::GitUtils.uncommitted_changes?(GeneratorMessages))
64+
!(missing_node? || missing_npm? || ReactOnRails::GitUtils.uncommitted_changes?(GeneratorMessages))
6565
end
6666

67-
def missing_yarn?
68-
return false unless ReactOnRails::Utils.running_on_windows? ? `where yarn`.blank? : `which yarn`.blank?
67+
def missing_npm?
68+
return false unless ReactOnRails::Utils.running_on_windows? ? `where npm`.blank? : `which npm`.blank?
6969

70-
error = "yarn is required. Please install it before continuing. https://yarnpkg.com/en/docs/install"
70+
error = "npm is required. Please install it before continuing. https://docs.npmjs.com/downloading-and-installing-node-js-and-npm"
7171
GeneratorMessages.add_error(error)
7272
true
7373
end

spec/react_on_rails/generators/install_generator_spec.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@
7878

7979
specify "when npm is exist" do
8080
stub_const("RUBY_PLATFORM", "linux")
81-
allow(install_generator).to receive(:`).with("which yarn").and_return("/path/to/bin")
82-
expect(install_generator.send(:missing_yarn?)).to be false
81+
allow(install_generator).to receive(:`).with("which npm").and_return("/path/to/bin")
82+
expect(install_generator.send(:missing_npm?)).to be false
8383
end
8484
end
8585

@@ -94,8 +94,8 @@
9494

9595
specify "when npm is missing" do
9696
stub_const("RUBY_PLATFORM", "linux")
97-
allow(install_generator).to receive(:`).with("which yarn").and_return("")
98-
expect(install_generator.send(:missing_yarn?)).to be true
97+
allow(install_generator).to receive(:`).with("which npm").and_return("")
98+
expect(install_generator.send(:missing_npm?)).to be true
9999
end
100100
end
101101

@@ -110,8 +110,8 @@
110110

111111
specify "when npm is exist" do
112112
stub_const("RUBY_PLATFORM", "mswin")
113-
allow(install_generator).to receive(:`).with("where yarn").and_return("/path/to/bin")
114-
expect(install_generator.send(:missing_yarn?)).to be false
113+
allow(install_generator).to receive(:`).with("where npm").and_return("/path/to/bin")
114+
expect(install_generator.send(:missing_npm?)).to be false
115115
end
116116
end
117117

@@ -124,10 +124,10 @@
124124
expect(install_generator.send(:missing_node?)).to be true
125125
end
126126

127-
specify "when yarn is missing" do
127+
specify "when npm is missing" do
128128
stub_const("RUBY_PLATFORM", "mswin")
129-
allow(install_generator).to receive(:`).with("where yarn").and_return("")
130-
expect(install_generator.send(:missing_yarn?)).to be true
129+
allow(install_generator).to receive(:`).with("where npm").and_return("")
130+
expect(install_generator.send(:missing_npm?)).to be true
131131
end
132132
end
133133
end

0 commit comments

Comments
 (0)