Skip to content

Commit

Permalink
Merge pull request rails#232 from aganov/fix/webpacker-check-node
Browse files Browse the repository at this point in the history
Fix nodejs and yarn checks
  • Loading branch information
matthewd authored Apr 6, 2017
2 parents 5e4f238 + decf4ab commit 7b83822
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions lib/tasks/webpacker/check_node.rake
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,11 @@ namespace :webpacker do
task :check_node do
begin
node_version = `node -v`
if node_version.tr("v", "").to_f < 6.4
puts "Webpacker requires Node.js >= 6.4 and you are using #{node_version}"
required_node_version = "6.4"

raise Errno::ENOENT if node_version.blank?
if Gem::Version.new(node_version.strip.tr("v", "")) < Gem::Version.new(required_node_version)
puts "Webpacker requires Node.js >= v#{required_node_version} and you are using #{node_version}"
puts "Please upgrade Node.js https://nodejs.org/en/download/"
puts "Exiting!" && exit!
end
Expand Down
3 changes: 2 additions & 1 deletion lib/tasks/webpacker/check_yarn.rake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ namespace :webpacker do
desc "Verifies if yarn is installed"
task :check_yarn do
begin
`yarn --version`
version = `yarn --version`
raise Errno::ENOENT if version.blank?
rescue Errno::ENOENT
puts "Webpacker requires yarn. Please download and install Yarn https://yarnpkg.com/lang/en/docs/install/"
puts "Exiting!" && exit!
Expand Down

0 comments on commit 7b83822

Please sign in to comment.