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

Commit 3e4e2fd

Browse files
fix(cli): pipe content to the cli from cat it is a stream
1 parent ebc93de commit 3e4e2fd

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

src/cli/commands/files/cat.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,17 @@ module.exports = {
1414

1515
handler (argv) {
1616
const path = argv['ipfs-path']
17+
1718
utils.getIPFS((err, ipfs) => {
1819
if (err) {
1920
throw err
2021
}
21-
if (utils.isDaemonOn()) {
22-
ipfs.cat(path, (err, res) => {
23-
if (err) {
24-
throw err
25-
}
26-
console.log(res.toString())
27-
})
28-
return
29-
}
22+
3023
ipfs.files.cat(path, (err, file) => {
3124
if (err) {
3225
throw (err)
3326
}
27+
3428
file.pipe(process.stdout)
3529
})
3630
})

test/cli/test-files.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ describe('files', () => {
8080
.run((err, stdout, exitcode) => {
8181
expect(err).to.not.exist
8282
expect(exitcode).to.equal(0)
83+
expect(stdout[0]).to.equal('hello world')
8384
done()
8485
})
8586
})

0 commit comments

Comments
 (0)