@@ -18,34 +18,48 @@ def run(path, options)
1818
1919 shield = nil
2020 begin
21- Timeout . timeout ( Badge . shield_io_timeout ) do
21+ timeout = Badge . shield_io_timeout
22+ timeout = options [ :shield_io_timeout ] unless not options [ :shield_io_timeout ]
23+ Timeout . timeout ( timeout . to_i ) do
2224 shield = load_shield ( options [ :shield ] ) unless not options [ :shield ]
2325 end
2426 rescue Timeout ::Error
2527 Helper . log . error "Error loading image from shield.io timeout reached. Skipping Shield. Use --verbose for more info" . red
2628 end
2729
30+ icon_changed = false
2831 app_icons . each do |full_path |
29- Helper . log . info "'#{ full_path } '"
3032 icon_path = Pathname . new ( full_path )
3133 icon = MiniMagick ::Image . new ( full_path )
3234
3335 result = MiniMagick ::Image . new ( full_path )
34- result = add_badge ( options [ :custom ] , options [ :dark ] , icon , options [ :alpha ] ) unless options [ :no_badge ]
35-
36- result = add_shield ( icon , result , shield ) unless not shield
37-
38- result . format "png"
39- result . write full_path
36+
37+ if !options [ :no_badge ]
38+ result = add_badge ( options [ :custom ] , options [ :dark ] , icon , options [ :alpha ] )
39+ icon_changed = true
40+ end
41+ if shield
42+ result = add_shield ( icon , result , shield )
43+ icon_changed = true
44+ end
45+
46+ if icon_changed
47+ result . format "png"
48+ result . write full_path
49+ end
50+ end
51+ if icon_changed
52+ Helper . log . info "Badged \\ o/!" . green
53+ else
54+ Helper . log . info "Did nothing... Enable --verbose for more info." . red
4055 end
41-
42- Helper . log . info "Badged \\ o/!" . green
4356 else
4457 Helper . log . error "Could not find any app icons..." . red
4558 end
4659 end
4760
4861 def add_shield ( icon , result , shield )
62+ Helper . log . info "'#{ icon . path } '"
4963 Helper . log . info "Adding shield.io image ontop of icon" . blue unless not $verbose
5064
5165 current_shield = MiniMagick ::Image . open ( shield . path )
@@ -71,6 +85,7 @@ def load_shield(shield_string)
7185 end
7286
7387 def add_badge ( custom_badge , dark_badge , icon , alpha_badge )
88+ Helper . log . info "'#{ icon . path } '"
7489 Helper . log . info "Adding badge image ontop of icon" . blue unless not $verbose
7590 if custom_badge && File . exist? ( custom_badge ) # check if custom image is provided
7691 badge = MiniMagick ::Image . open ( custom_badge )
0 commit comments