Class: Npm::Rails::PackageBundler

Inherits:
Object
  • Object
show all
Defined in:
lib/npm/rails/package_bundler.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.bundle(root_path, package_file, env, &block) ⇒ Object



6
7
8
# File 'lib/npm/rails/package_bundler.rb', line 6

def self.bundle(root_path, package_file, env, &block)
  new.bundle(root_path, package_file, env, &block)
end

Instance Method Details

#bundle(root_path, package_file, env, &block) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/npm/rails/package_bundler.rb', line 10

def bundle(root_path, package_file, env, &block)
  @root_path = root_path
  @package_file = package_file
  @env = env

  if File.exist?("#{ root_path }/#{ package_file }")
    bundle_file_path = package_manager.write_bundle_file
    if block_given?
      yield package_manager.to_npm_format, bundle_file_path
    end
  else
    raise PackageFileNotFound, "#{ package_file } not found! Make sure you have it at the root of your project"
  end
end