Skip to content

Commit 3139d59

Browse files
committed
- Refactor libraries
1 parent 0012108 commit 3139d59

26 files changed

+73
-76
lines changed

lib/bashly/commands/add.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,16 @@ def yaml_command
107107
private
108108

109109
def add_lib(name, *args)
110-
library = Bashly::Library.new name, *args
110+
source = Bashly::LibrarySource.new
111+
library = source.libraries[name.to_sym]
112+
library.args = args
113+
111114
files_created = 0
112115
library.files.each do |file|
113116
created = safe_write file[:path], file[:content]
114117
files_created += 1 if created
115118
end
119+
116120
message = library.post_install_message
117121
say "\n#{message}" if message && files_created.positive?
118122
end

lib/bashly/commands/generate.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,19 @@ def generated_files
9292
end
9393

9494
def upgrade(existing_file, library_name, *args)
95-
if Library.exist? library_name
96-
upgrade! existing_file, library_name, *args
95+
source = Bashly::LibrarySource.new
96+
library = source.libraries[library_name.to_sym]
97+
98+
if library
99+
library.args = args
100+
upgrade! existing_file, library
97101
else
98102
quiet_say "r`warning` not upgrading c`#{existing_file}`, " \
99103
"unknown library '#{library_name}'"
100104
end
101105
end
102106

103-
def upgrade!(existing_file, library_name, *args)
104-
library = Bashly::Library.new library_name, *args
107+
def upgrade!(existing_file, library)
105108
file = library.find_file existing_file
106109

107110
if file
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def post_install_message
2929
private
3030

3131
def help_command
32-
asset_content('templates/lib/help_command.sh') % { name: command.name }
32+
asset_content('libraries/help/help_command.sh') % { name: command.name }
3333
end
3434
end
3535
end
File renamed without changes.

0 commit comments

Comments
 (0)