Sha256: 6164a0612de77b59ade2501327fa04177f022a9654fd3802eb90624bbfd81481

Contents?: true

Size: 1.26 KB

Versions: 16

Compression:

Stored size: 1.26 KB

Contents

require "semantic_range"
namespace :shakapacker do
  desc "Verifies if Node.js is installed"
  task :check_node do
    begin
      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 "Shakapacker 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

16 entries across 16 versions & 1 rubygems

Version Path
shakapacker-8.0.2 lib/tasks/shakapacker/check_node.rake
shakapacker-8.0.1 lib/tasks/shakapacker/check_node.rake
shakapacker-7.2.3 lib/tasks/shakapacker/check_node.rake
shakapacker-7.3.0.beta.1 lib/tasks/shakapacker/check_node.rake
shakapacker-7.2.2 lib/tasks/shakapacker/check_node.rake
shakapacker-7.2.1 lib/tasks/shakapacker/check_node.rake
shakapacker-7.2.0 lib/tasks/shakapacker/check_node.rake
shakapacker-7.2.0.rc.0 lib/tasks/shakapacker/check_node.rake
shakapacker-7.1.0 lib/tasks/shakapacker/check_node.rake
shakapacker-7.0.3 lib/tasks/shakapacker/check_node.rake
shakapacker-7.0.2 lib/tasks/shakapacker/check_node.rake
shakapacker-7.0.1 lib/tasks/shakapacker/check_node.rake
shakapacker-7.0.0 lib/tasks/shakapacker/check_node.rake
shakapacker-7.0.0.rc.2 lib/tasks/shakapacker/check_node.rake
shakapacker-7.0.0.rc.1 lib/tasks/shakapacker/check_node.rake
shakapacker-7.0.0.rc.0 lib/tasks/shakapacker/check_node.rake