Sha256: ec4b6279fd501b72234e5f6b4efc2cf257390e554b2b902ea548cba05699c58d

Contents?: true

Size: 633 Bytes

Versions: 12

Compression:

Stored size: 633 Bytes

Contents

module SpecifiedNode
  extend self

  NODE_VERSION = "v12.16.1"
  NODE_PATH = "tmp/node-#{NODE_VERSION}-linux-x64/bin/node"

  def ensure!
    install_node unless node_installed?
    install_binstub
    "bin/node --version"
  end

  private

  def install_node
    system("wget -cO- https://nodejs.org/dist/#{NODE_VERSION}/node-#{NODE_VERSION}-linux-x64.tar.xz | tar xJ -C tmp/")
  end

  def install_binstub
    system("cd bin && ln -fs ../#{NODE_PATH}")
  end

  def node_installed?
    File.exist?(NODE_PATH) && `#{NODE_PATH} --version`.chomp == NODE_VERSION
  end

  def binstub_installed?
    File.exist?("bin/node")
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
bard-0.49.0 install_files/specified_node.rb
bard-0.48.1 install_files/specified_node.rb
bard-0.48.0 install_files/specified_node.rb
bard-0.47.0 install_files/specified_node.rb
bard-0.46.0 install_files/specified_node.rb
bard-0.45.1 install_files/specified_node.rb
bard-0.45.0 install_files/specified_node.rb
bard-0.44.2 install_files/specified_node.rb
bard-0.44.1 install_files/specified_node.rb
bard-0.44.0 install_files/specified_node.rb
bard-0.43.2 install_files/specified_node.rb
bard-0.43.0 install_files/specified_node.rb