# All files / lib df.js

93.75% Statements 15/16
85.71% Branches 12/14
100% Functions 3/3
93.75% Lines 15/16

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    1x

    12x
    4x

    12x
    4x

    12x
    12x

    12x
    12x
    1x

    11x

    11x

    11x

    1x

    1x

     'use strict'
    ;(function(DFHelper, exec, _) {
        function df(options, callback) {
            if (!_.isFunction(callback)) {
                callback = _.isFunction(options) ? options : DFHelper.noop
            }

            if (_.isFunction(options) || !_.isObject(options)) {
                options = {}
            }

            var baseCmd = 'df -kP'
            var cmd = options.file ? baseCmd + ' ' + options.file : baseCmd

            exec(cmd, function(error, stdout, stderr) {
                if (error) {
                    return callback(error)
                }

                Iif (stderr) {
                    return callback(new Error(stderr))
                }

                var response = DFHelper.parse(stdout, options)

                callback(null, response)
            })
        }

        df.Helper = DFHelper

        module.exports = df
    })(require('./helpers/DFHelper'), require('child_process').exec, require('underscore'))