Class: Esbuild::BinaryInstaller

Inherits:
Object
  • Object
show all
Defined in:
lib/esbuild/binary_installer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(platform, path) ⇒ BinaryInstaller

Returns a new instance of BinaryInstaller.

Raises:

  • (ArgumentError)


9
10
11
12
13
14
# File 'lib/esbuild/binary_installer.rb', line 9

def initialize(platform, path)
  package = package_from_platform(platform)
  raise ArgumentError, "Unknown platform #{platform}" unless package
  @package = package
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



8
9
10
# File 'lib/esbuild/binary_installer.rb', line 8

def path
  @path
end

#platformObject (readonly)

Returns the value of attribute platform.



8
9
10
# File 'lib/esbuild/binary_installer.rb', line 8

def platform
  @platform
end

Instance Method Details

#installObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/esbuild/binary_installer.rb', line 16

def install
  tempfile = "#{@path}__"
  if ENV["ESBUILD_BINARY_PATH"]
    FileUtils.cp(ENV["ESBUILD_BINARY_PATH"], tempfile)
  else
    # TODO: use cache
    download(tempfile)
  end

  validate_binary_version!(tempfile)
  FileUtils.mv(tempfile, @path)
end