Skip to content

Commit e04231c

Browse files
authored
Merge branch 'master' into justin800/allow-router-result-to-return-html-string
2 parents 0512a2b + 4e567a3 commit e04231c

File tree

4 files changed

+81
-4
lines changed

4 files changed

+81
-4
lines changed

CHANGELOG.md

+11-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,17 @@ Contributors: please follow the recommendations outlined at [keepachangelog.com]
66
## [Unreleased]
77
*Please add entries here for your pull requests.*
88

9+
## [6.4.2] - 2017-1-17
10+
### Fixed
11+
- Added OS detection for install generator, system call for Windows and unit-tests for it. [#666](https://github.com/shakacode/react_on_rails/pull/666) by [GeorgeGorbanev](https://github.com/GeorgeGorbanev).
12+
13+
## [6.4.1] - 2017-1-17
14+
No changes.
15+
916
## [6.4.0] - 2017-1-12
1017

1118
### Possible Breaking Change
12-
- Since foreman is no longer a dependency of the React on Rails gem, please run `gem install foreman`. If you are using rvm, you may wish to run `rvm @global do gem install foreman` to install foreman for all your gemsets.
19+
- Since foreman is no longer a dependency of the React on Rails gem, please run `gem install foreman`. If you are using rvm, you may wish to run `rvm @global do gem install foreman` to install foreman for all your gemsets.
1320

1421
### Fixed
1522
- Removed foreman as a dependency. [#678](https://github.com/shakacode/react_on_rails/pull/678) by [x2es](https://github.com/x2es).
@@ -428,7 +435,9 @@ Best done with Object destructing:
428435
##### Fixed
429436
- Fix several generator related issues.
430437

431-
[Unreleased]: https://github.com/shakacode/react_on_rails/compare/6.4.0...master
438+
[Unreleased]: https://github.com/shakacode/react_on_rails/compare/6.4.2...master
439+
[6.4.2]: https://github.com/shakacode/react_on_rails/compare/6.4.1...6.4.2
440+
[6.4.1]: https://github.com/shakacode/react_on_rails/compare/6.4.0...6.4.1
432441
[6.4.0]: https://github.com/shakacode/react_on_rails/compare/6.3.5...6.4.0
433442
[6.3.5]: https://github.com/shakacode/react_on_rails/compare/6.3.4...6.3.5
434443
[6.3.4]: https://github.com/shakacode/react_on_rails/compare/6.3.3...6.3.4

lib/generators/react_on_rails/install_generator.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ def installation_prerequisites_met?
6464
end
6565

6666
def missing_npm?
67-
return false unless `which npm`.blank?
67+
return false unless ReactOnRails::Utils.running_on_windows? ? `where npm`.blank? : `which npm`.blank?
6868
error = "npm is required. Please install it before continuing. "
6969
error << "https://www.npmjs.com/"
7070
GeneratorMessages.add_error(error)
7171
true
7272
end
7373

7474
def missing_node?
75-
return false unless `which node`.blank?
75+
return false unless ReactOnRails::Utils.running_on_windows? ? `where node`.blank? : `which node`.blank?
7676
error = "** nodejs is required. Please install it before continuing. "
7777
error << "https://nodejs.org/en/"
7878
GeneratorMessages.add_error(error)

lib/react_on_rails/utils.rb

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ def self.default_server_bundle_js_file_path
2020
ReactOnRails.configuration.server_bundle_js_file)
2121
end
2222

23+
def self.running_on_windows?
24+
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
25+
end
26+
2327
module Required
2428
def required(arg_name)
2529
raise ArgumentError, "#{arg_name} is required"

spec/react_on_rails/generators/install_generator_spec.rb

+64
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,68 @@
111111
.to include(GeneratorMessages.format_info(expected))
112112
end
113113
end
114+
115+
context "detect existing bin-files on *nix" do
116+
before(:all) { @install_generator = InstallGenerator.new }
117+
118+
specify "when node is exist" do
119+
stub_const("RUBY_PLATFORM", "linux")
120+
allow(@install_generator).to receive(:`).with("which node").and_return("/path/to/bin")
121+
expect(@install_generator.send(:missing_node?)).to eq false
122+
end
123+
124+
specify "when npm is exist" do
125+
stub_const("RUBY_PLATFORM", "linux")
126+
allow(@install_generator).to receive(:`).with("which npm").and_return("/path/to/bin")
127+
expect(@install_generator.send(:missing_npm?)).to eq false
128+
end
129+
end
130+
131+
context "detect missing bin-files on *nix" do
132+
before(:all) { @install_generator = InstallGenerator.new }
133+
134+
specify "when node is missing" do
135+
stub_const("RUBY_PLATFORM", "linux")
136+
allow(@install_generator).to receive(:`).with("which node").and_return("")
137+
expect(@install_generator.send(:missing_node?)).to eq true
138+
end
139+
140+
specify "when npm is missing" do
141+
stub_const("RUBY_PLATFORM", "linux")
142+
allow(@install_generator).to receive(:`).with("which npm").and_return("")
143+
expect(@install_generator.send(:missing_npm?)).to eq true
144+
end
145+
end
146+
147+
context "detect existing bin-files on windows" do
148+
before(:all) { @install_generator = InstallGenerator.new }
149+
150+
specify "when node is exist" do
151+
stub_const("RUBY_PLATFORM", "mswin")
152+
allow(@install_generator).to receive(:`).with("where node").and_return("/path/to/bin")
153+
expect(@install_generator.send(:missing_node?)).to eq false
154+
end
155+
156+
specify "when npm is exist" do
157+
stub_const("RUBY_PLATFORM", "mswin")
158+
allow(@install_generator).to receive(:`).with("where npm").and_return("/path/to/bin")
159+
expect(@install_generator.send(:missing_npm?)).to eq false
160+
end
161+
end
162+
163+
context "detect missing bin-files on windows" do
164+
before(:all) { @install_generator = InstallGenerator.new }
165+
166+
specify "when node is missing" do
167+
stub_const("RUBY_PLATFORM", "mswin")
168+
allow(@install_generator).to receive(:`).with("where node").and_return("")
169+
expect(@install_generator.send(:missing_node?)).to eq true
170+
end
171+
172+
specify "when npm is missing" do
173+
stub_const("RUBY_PLATFORM", "mswin")
174+
allow(@install_generator).to receive(:`).with("where npm").and_return("")
175+
expect(@install_generator.send(:missing_npm?)).to eq true
176+
end
177+
end
114178
end

0 commit comments

Comments
 (0)