inline prettyBytes
This commit is contained in:
@@ -40,7 +40,6 @@ const assert = require('assert'),
|
||||
mounts = require('../mounts.js'),
|
||||
path = require('path'),
|
||||
paths = require('../paths.js'),
|
||||
prettyBytes = require('../pretty-bytes.js'),
|
||||
readdirp = require('readdirp'),
|
||||
safe = require('safetydance'),
|
||||
shell = require('../shell.js');
|
||||
@@ -62,6 +61,16 @@ function getRootPath(apiConfig) {
|
||||
}
|
||||
}
|
||||
|
||||
// binary units (non SI) 1024 based
|
||||
function prettyBytes(size) {
|
||||
assert.strictEqual(typeof size, 'number');
|
||||
|
||||
if (!size) return 0;
|
||||
|
||||
const i = Math.floor(Math.log(size) / Math.log(1024));
|
||||
return (size / Math.pow(1024, i)).toFixed(2) * 1 + ' ' + ['B', 'kB', 'MB', 'GB', 'TB'][i];
|
||||
}
|
||||
|
||||
// the du call in the function below requires root
|
||||
async function checkPreconditions(apiConfig, dataLayout) {
|
||||
assert.strictEqual(typeof apiConfig, 'object');
|
||||
|
||||
Reference in New Issue
Block a user