Skip to content

Commit

Permalink
alternative approach
Browse files Browse the repository at this point in the history
  • Loading branch information
johndbritton committed Dec 16, 2020
1 parent 477f555 commit 78adf4d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/bundle/commands/add.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ def run(*args, global: false, file: nil)
name = args.first # only support one formula at a time for now
options = {} # we don't currently support passing options

# read the relevant Brewfile
parsed_entries = Bundle::Dsl.new(Brewfile.read(global: global, file: file)).entries
# parse the relevant Brewfile
dsl = Bundle::Dsl.new(Brewfile.read(global: global, file: file))

# check each of the entries in the specified Brewfile
parsed_entries.each do |entry|
dsl.entries.each do |entry|
# raise an error if the entry already exists in the Brewfile
# this could also be a noop, or print a friendly message
opoo "'#{name}' already exists in Brewfile."
raise RuntimeError if entry.name == name
end

# need some help / pointers here
# is it possible to use Bundle::Dsl to create an in memory representation
# of the brewfile that we read, add an entry and then dump that back to the file?
dsl.brew(name, options)
# execute brew bundle
# execute brew bundle dump
end
end
end
Expand Down

0 comments on commit 78adf4d

Please sign in to comment.