mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-15 14:20:38 +08:00
26 lines
731 B
CoffeeScript
26 lines
731 B
CoffeeScript
|
module.exports = (grunt) ->
|
||
|
{spawn} = require('./task-helpers')(grunt)
|
||
|
|
||
|
grunt.registerTask 'output-disk-space', 'Print diskspace available', ->
|
||
|
return unless process.platform is 'darwin'
|
||
|
|
||
|
done = @async()
|
||
|
|
||
|
cmd = 'df'
|
||
|
args = ['-Hl']
|
||
|
spawn {cmd, args}, (error, result, code) ->
|
||
|
return done(error) if error?
|
||
|
|
||
|
lines = result.stdout.split("\n")
|
||
|
|
||
|
for line in lines[1..]
|
||
|
[filesystem, size, used, avail, capacity, extra] = line.split(/\s+/)
|
||
|
capacity = parseInt(capacity)
|
||
|
|
||
|
if capacity > 90
|
||
|
grunt.log.error("#{filesystem} is at #{capacity}% capacity!")
|
||
|
else if capacity > 80
|
||
|
grunt.log.ok("#{filesystem} is at #{capacity}% capacity.")
|
||
|
|
||
|
done()
|