diff --git a/src/cli/commands/files/cat.js b/src/cli/commands/files/cat.js index e2be436765..a28a22e6e9 100644 --- a/src/cli/commands/files/cat.js +++ b/src/cli/commands/files/cat.js @@ -14,19 +14,23 @@ module.exports = { handler (argv) { const path = argv['ipfs-path'] - utils.getIPFS((err, ipfs) => { if (err) { throw err } - ipfs.files.cat(path, (err, file) => { - if (err) { - throw (err) - } + if (utils.isDaemonOn()) { + return ipfs.cat(path, onFile) + } - file.pipe(process.stdout) - }) + ipfs.files.cat(path, onFile) }) } } + +function onFile (err, file) { + if (err) { + throw (err) + } + file.pipe(process.stdout) +}