Skip to content

Commit 5885694

Browse files
committed
improvements
1 parent 188bd9e commit 5885694

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

lib/bashly/commands/generate.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ def upgrade_libs
3535
content = File.read file
3636

3737
if content =~ /\[@bashly-upgrade (.+)\]/
38-
library_name, args = $1.split(' ', 2)
38+
args = $1.split ' '
39+
library_name = args.shift
3940
upgrade file, library_name, *args
4041
end
4142
end
@@ -55,7 +56,7 @@ def upgrade(existing_file, library_name, *args)
5556

5657
def upgrade!(existing_file, library_name, *args)
5758
library = Bashly::Library.new library_name, *args
58-
file = library.files.select { |f| f[:path] == existing_file }.first
59+
file = library.find_file existing_file
5960

6061
if file
6162
File.deep_write file[:path], file[:content]

lib/bashly/library.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def initialize(name, *args)
2222
end
2323

2424
def files
25-
if config.is_a? Symbol
25+
if custom_handler
2626
custom_handler.files
2727

2828
else
@@ -34,16 +34,21 @@ def files
3434
end
3535

3636
def post_install_message
37-
if config.is_a? Symbol
37+
if custom_handler
3838
custom_handler.post_install_message
3939
else
4040
config['post_install_message']
4141
end
4242
end
4343

44+
def find_file(path)
45+
files.select { |f| f[:path] == path }.first
46+
end
47+
4448
private
4549

4650
def custom_handler
51+
return nil unless config.is_a? Symbol
4752
@custom_handler ||= Bashly::Libraries.const_get(config).new(*args)
4853
end
4954

0 commit comments

Comments
 (0)