Class: Fastlane::Actions::UpdateCopyrightAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::UpdateCopyrightAction
- Defined in:
- lib/fastlane/plugin/stream_actions/actions/update_copyright.rb
Documentation collapse
Class Method Summary collapse
Class Method Details
.available_options ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/fastlane/plugin/stream_actions/actions/update_copyright.rb', line 34 def self. [ FastlaneCore::ConfigItem.new( key: :path, description: 'A path to search for files to update', default_value: '.' ), FastlaneCore::ConfigItem.new( key: :ignore, description: 'The folders to ignore', is_string: false, default_value: [] ) ] end |
.description ⇒ Object
30 31 32 |
# File 'lib/fastlane/plugin/stream_actions/actions/update_copyright.rb', line 30 def self.description 'Updates copyright headers in source files' end |
.is_supported?(platform) ⇒ Boolean
50 51 52 |
# File 'lib/fastlane/plugin/stream_actions/actions/update_copyright.rb', line 50 def self.is_supported?(platform) [:ios].include?(platform) end |
.run(params) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/fastlane/plugin/stream_actions/actions/update_copyright.rb', line 4 def self.run(params) new_year = Time.now.year.to_s ext = '*.{swift,h,strings,pbxproj}' source_files = Dir.glob(File.join(params[:path], '**', ext)).reject do |f| params[:ignore].any? { |dir| f.include?(dir) } end source_files.each do |file_path| UI.("👀 Searching for copyright header in #{File.absolute_path(file_path)}") old_content = File.read(file_path) match = old_content.match(/Copyright © (\d{4}) Stream.io/) next if !match || match[1] == new_year old_year = match[1] new_content = old_content.gsub("Copyright © #{old_year}", "Copyright © #{new_year}") File.write(file_path, new_content) UI.success("✅ Updated copyright header in #{File.absolute_path(file_path)}") end end |