mirror of
https://github.com/chromebrew/chromebrew.git
synced 2026-01-08 23:18:10 -05:00
Add check_free_disk_space misc function (#10536)
* Add check_free_disk_space misc function * Remove require 'matrix' line in misc_functions.rb
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
# lib/misc_functions.rb
|
||||
# Generic implementations of various functions/algorithms that are not crew-specific.
|
||||
require_relative 'color'
|
||||
|
||||
def require_gem(gem_name_and_require = nil, require_override = nil)
|
||||
# Allow only loading gems when needed.
|
||||
return if gem_name_and_require.nil?
|
||||
@@ -91,4 +93,10 @@ class MiscFunctions
|
||||
time_seconds_string = "#{time_seconds} second#{time_seconds == 1 ? '' : 's'}"
|
||||
return time_hour_string + time_minutes_string + time_seconds_string
|
||||
end
|
||||
|
||||
def self.check_free_disk_space(bytes = 0)
|
||||
formatted_size = human_size(bytes)
|
||||
free_space = `echo $(($(stat -f --format="%a*%S" #{CREW_PREFIX})))`.chomp.to_i
|
||||
abort "\nNot enough free disk space. You need at least #{formatted_size} to install.\n".lightred if free_space < bytes
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user