class EmbeddedJs::PackageConfig

Attributes

config[R]
path[R]

Public Class Methods

new(package_path) click to toggle source
# File lib/embedded_js/package_config.rb, line 9
def initialize(package_path)
  @path = package_path

  raise ArgumentError, "#{package_path} does not have a package.json file." unless File.exist?(config_path)

  @config = JSON.parse(File.read(config_path))
end

Public Instance Methods

package_files_paths() click to toggle source
# File lib/embedded_js/package_config.rb, line 17
def package_files_paths
  specified_files.map { |f| "#{path}/#{f}" }.tap do |paths|
    paths << config_path unless paths.include?(config_path)
  end
end

Private Instance Methods

config_path() click to toggle source
# File lib/embedded_js/package_config.rb, line 27
def config_path
  "#{path}/package.json"
end
specified_files() click to toggle source
# File lib/embedded_js/package_config.rb, line 31
def specified_files
  config.fetch('files', [])
end