Js-ipfs: Different CLI output for jsipfs add

Created on 13 Jan 2019  路  5Comments  路  Source: ipfs/js-ipfs

When adding a file or folder, both go-ipfs and js-ipfs print to the console something like:

added QmVes6R29KZ18VizBmuUmppFAbVjbxV2iYGz41pAdeDPdS public/tags/stream

However, when go-ipfs gets piped into another command, it commits both the added and public/tags/stream and only passes the hash, while js-ipfs send the whole thing.

The difference in behavior makes it so that it is hard to switch back and forth as this breaks some tooling to (for example) publish websites.

P2 dihard help wanted kinbug

Most helpful comment

All 5 comments

I'm unaware of how the node process would know it is being piped - I've never needed it before!

Are you sure this is the case? I just saw https://github.com/ipfs/ipfs/issues/337#issuecomment-455164513 and Kyle is using the -q flag to make the output only include CIDs.

FWIW, you can find out if stdin/stdout is being piped by inspecting the isTTY property - e.g. process.stdout.isTTY will be false if the current processes' output is being piped to another process.

Go IPFS:

$ echo "hello" | ipfs add | cat
 6 B / ? [--------------------------------------------------------------=-----] added QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN
$ echo "hello" | ipfs add -q | cat
QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN

I think what you might have been seeing was js-ipfs adding "added" even if -q was set. I fixed this here and it has been released in js-ipfs 0.34.1:

$ echo "hello" | jsipfs add | cat
added QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN
$ echo "hello" | jsipfs add -q | cat
QmZULkCELmmk5XNfCgTnCyFgAVxBRBXyDHGGMVoLFLiXEN
Was this page helpful?
0 / 5 - 0 ratings

Related issues

lifeBCE picture lifeBCE  路  3Comments

dryajov picture dryajov  路  3Comments

beingmohit picture beingmohit  路  3Comments

mitra42 picture mitra42  路  3Comments

Ntmf picture Ntmf  路  4Comments