diff --git a/package.json b/package.json index ac8b1167cb..2a5205ffad 100644 --- a/package.json +++ b/package.json @@ -109,7 +109,8 @@ "debug": "^4.1.0", "dlv": "^1.1.3", "err-code": "^1.1.2", - "file-type": "^11.1.0", + "file-type": "^11.0.0", + "filesize": "^4.1.2", "fnv1a": "^1.0.1", "fsm-event": "^2.1.0", "get-folder-size": "^2.0.0", diff --git a/src/cli/commands/repo/stat.js b/src/cli/commands/repo/stat.js index 660a7ff444..a7bab3cf1f 100644 --- a/src/cli/commands/repo/stat.js +++ b/src/cli/commands/repo/stat.js @@ -1,6 +1,6 @@ 'use strict' -const print = require('../../utils').print +const filesize = require('filesize') module.exports = { command: 'stat', @@ -17,13 +17,17 @@ module.exports = { handler (argv) { argv.resolve((async () => { const ipfs = await argv.getIpfs() - const stats = await ipfs.repo.stat({ human: argv.human }) - print(`repo status + const stats = await ipfs.repo.stat() + if (argv.human) { + stats.repoSize = filesize(stats.repoSize) + stats.storageMax = filesize(stats.storageMax) + } + return `repo status number of objects: ${stats.numObjects} repo size: ${stats.repoSize} repo path: ${stats.repoPath} version: ${stats.version} - maximum storage: ${stats.storageMax}`) + maximum storage: ${stats.storageMax}` })()) } } diff --git a/src/cli/commands/stats/repo.js b/src/cli/commands/stats/repo.js index 343b8d9617..4abf5f45cd 100644 --- a/src/cli/commands/stats/repo.js +++ b/src/cli/commands/stats/repo.js @@ -1,6 +1,6 @@ 'use strict' -const print = require('../../utils').print +const filesize = require('filesize') module.exports = { command: 'repo', @@ -17,13 +17,17 @@ module.exports = { handler (argv) { argv.resolve((async () => { const ipfs = await argv.getIpfs() - const stats = await ipfs.stats.repo({ human: argv.human }) - print(`repo status + const stats = await ipfs.stats.repo() + if (argv.human) { + stats.repoSize = filesize(stats.repoSize) + stats.storageMax = filesize(stats.storageMax) + } + return `repo status number of objects: ${stats.numObjects} repo size: ${stats.repoSize} repo path: ${stats.repoPath} version: ${stats.version} - maximum storage: ${stats.storageMax}`) + maximum storage: ${stats.storageMax}` })()) } }