Class: Grundler::PackageJsonWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/grundler/package_json_writer.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ PackageJsonWriter

Returns a new instance of PackageJsonWriter.



5
6
7
# File 'lib/grundler/package_json_writer.rb', line 5

def initialize(path)
  @path = path
end

Instance Method Details

#add(packages) ⇒ Object



9
10
11
# File 'lib/grundler/package_json_writer.rb', line 9

def add(packages)
  write(existing_packages.merge(packages))
end

#existing_packagesObject



19
20
21
# File 'lib/grundler/package_json_writer.rb', line 19

def existing_packages
  existing_content["dependencies"]
end

#remove(packages) ⇒ Object



13
14
15
16
17
# File 'lib/grundler/package_json_writer.rb', line 13

def remove(packages)
  write(
    existing_packages.delete_if { |k, _v| packages.include?(k) }
  )
end