Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
fix(cli): pipe content to the cli from cat it is a stream
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Sep 12, 2016
1 parent ebc93de commit 3e4e2fd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/cli/commands/files/cat.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,17 @@ module.exports = {

handler (argv) {
const path = argv['ipfs-path']

utils.getIPFS((err, ipfs) => {
if (err) {
throw err
}
if (utils.isDaemonOn()) {
ipfs.cat(path, (err, res) => {
if (err) {
throw err
}
console.log(res.toString())
})
return
}

ipfs.files.cat(path, (err, file) => {
if (err) {
throw (err)
}

file.pipe(process.stdout)
})
})
Expand Down
1 change: 1 addition & 0 deletions test/cli/test-files.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ describe('files', () => {
.run((err, stdout, exitcode) => {
expect(err).to.not.exist
expect(exitcode).to.equal(0)
expect(stdout[0]).to.equal('hello world')
done()
})
})
Expand Down

0 comments on commit 3e4e2fd

Please sign in to comment.