'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var nodejs_child_process = require('../nodejs/child_process.js');

function getAvailableDiskSize(options) {
  var _getChildProcess = nodejs_child_process.getChildProcess(),
    execSync = _getChildProcess.execSync;
  var command = 'df -P';
  var log = (options === null || options === void 0 ? void 0 : options.mockLog) || '';
  if (!log) {
    log = execSync(command, {
      stdio: 'pipe',
      encoding: 'utf-8'
    });
  }
  console.log('[log]', log);
  var list = log.split('\n');
  console.log('[list]', list);
  var detailList = list.map(function (item) {
    return item.trim();
  }).filter(function (item) {
    return item;
  }).slice(1).map(function (item) {
    return item.split(/\s+/);
  });
  console.log('[detailList]', detailList);
  var dataLog = detailList.find(function (item) {
    return item[5] === '/data';
  });
  console.log('[dataLog]', dataLog);
  if (!dataLog) return 0;
  var available = +dataLog[3];
  console.log('[available]', available);
  return available;
}

exports.getAvailableDiskSize = getAvailableDiskSize;
