Sha256: d4fe1c34c9e025bee886306565a81deec345ee42e4a65b508b11638dc381e15d
Contents?: true
Size: 1.33 KB
Versions: 1
Compression:
Stored size: 1.33 KB
Contents
require "semantic_range" namespace :webpacker do desc "Verifies if Node.js is installed" task :check_node do begin raise Errno::ENOENT if `which node || which nodejs`.strip.empty? node_version = `node -v || nodejs -v`.strip raise Errno::ENOENT if node_version.blank? pkg_path = Pathname.new("#{__dir__}/../../../package.json").realpath node_range = JSON.parse(pkg_path.read)["engines"]["node"] is_valid = SemanticRange.satisfies?(node_version, node_range) rescue false semver_major = node_version[/\d+/] rescue nil is_unstable = semver_major.to_i.odd? rescue false if is_unstable $stderr.puts "Warning: you are using an unstable release of Node.js (#{node_version}). If you encounter issues with Node.js, consider switching to an Active LTS release. More info: https://docs.npmjs.com/try-the-latest-stable-version-of-node" end unless is_valid $stderr.puts "Webpacker requires Node.js \"#{node_range}\" and you are using #{node_version}" $stderr.puts "Please upgrade Node.js https://nodejs.org/en/download/" $stderr.puts "Exiting!" exit! end rescue Errno::ENOENT $stderr.puts "Node.js not installed. Please download and install Node.js https://nodejs.org/en/download/" $stderr.puts "Exiting!" exit! end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
webpacker-6.0.0.beta.7 | lib/tasks/webpacker/check_node.rake |