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

fix(cli): pipe content to the cli from cat it is a stream #482

Merged
merged 3 commits into from
Sep 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"detect-node": "^2.0.3",
"glob": "^7.0.6",
"hapi": "^15.0.3",
"ipfs-api": "^8.0.3",
"ipfs-api": "^8.0.4",
"ipfs-bitswap": "^0.7.0",
"ipfs-block": "^0.3.0",
"ipfs-block-service": "^0.5.0",
Expand Down Expand Up @@ -132,4 +132,4 @@
"nginnever <ginneversource@gmail.com>",
"npmcdn-to-unpkg-bot <npmcdn-to-unpkg-bot@users.noreply.github.com>"
]
}
}
12 changes: 9 additions & 3 deletions src/cli/commands/files/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,17 @@ module.exports = {
const index = inPath.lastIndexOf('/') + 1

utils.getIPFS((err, ipfs) => {
if (err) throw err
if (err) {
throw err
}

glob(path.join(inPath, '/**/*'), (err, list) => {
if (err) throw err
if (list.length === 0) list = [inPath]
if (err) {
throw err
}
if (list.length === 0) {
list = [inPath]
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't do style changes in a bug fix commit :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack, will avoid in future PR. Reverting just this and do another PR doesn't seem necessary.


pull(
zip(
Expand Down
24 changes: 9 additions & 15 deletions src/cli/commands/files/cat.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,15 @@ module.exports = {
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)
})

ipfs.files.cat(path, onFile)
})
}
}

function onFile (err, file) {
if (err) {
throw (err)
}
file.pipe(process.stdout)
}
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