Sha256: 84d03f14d755a8534c1dcf69059144186b70ee9e0a0e23c6c5cf3ba86eedaafd

Contents?: true

Size: 984 Bytes

Versions: 10

Compression:

Stored size: 984 Bytes

Contents

module Potassium
  class NodeVersionEnsurer
    def ensure!
      raise VersionError.new(install_message) if installed_node_version.nil?
      raise VersionError.new(update_message) if Potassium::NODE_VERSION != installed_node_version
    end

    private

    def installed_node_version
      node_version = `node -v 2>&1`
      return node_version.delete('^[0-9\.]').split('.').first if $?.success?
    end

    def install_message
      <<~HERE
        Node doesn't appear to be installed.
        Please make sure you have node #{Potassium::NODE_VERSION} installed.
      HERE
    end

    def update_message
      <<~HERE
        An unsupported version of node was found.
        Please make sure you have node #{Potassium::NODE_VERSION} installed. Newer versions may work but potassium only supports that one.
        If you really need to run potassium with a different version of node, re-run this command with the `--no-node-version-check` flag.
      HERE
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
potassium-7.2.0 lib/potassium/node_version_ensurer.rb
potassium-7.1.0 lib/potassium/node_version_ensurer.rb
potassium-7.0.0 lib/potassium/node_version_ensurer.rb
potassium-6.7.0 lib/potassium/node_version_ensurer.rb
potassium-6.6.0 lib/potassium/node_version_ensurer.rb
potassium-6.5.0 lib/potassium/node_version_ensurer.rb
potassium-6.4.0 lib/potassium/node_version_ensurer.rb
potassium-6.3.0 lib/potassium/node_version_ensurer.rb
potassium-6.2.0 lib/potassium/node_version_ensurer.rb
potassium-6.1.0 lib/potassium/node_version_ensurer.rb