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

Different CLI output for jsipfs add #1813

Closed
daviddias opened this issue Jan 13, 2019 · 5 comments
Closed

Different CLI output for jsipfs add #1813

daviddias opened this issue Jan 13, 2019 · 5 comments
Labels
exp/expert Having worked on the specific codebase is important help wanted Seeking public contribution on this issue kind/bug A bug in existing code (including security flaws) P2 Medium: Good to have, but can wait until someone steps up

Comments

@daviddias
Copy link
Member

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.

@daviddias daviddias added the kind/bug A bug in existing code (including security flaws) label Jan 13, 2019
@alanshaw alanshaw added exp/expert Having worked on the specific codebase is important help wanted Seeking public contribution on this issue status/ready Ready to be worked P2 Medium: Good to have, but can wait until someone steps up labels Jan 14, 2019
@alanshaw
Copy link
Member

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

@alanshaw
Copy link
Member

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.

@achingbrain
Copy link
Member

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.

@alanshaw
Copy link
Member

alanshaw commented Jan 21, 2019

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

@ghost ghost removed the status/ready Ready to be worked label Jan 21, 2019
@daviddias
Copy link
Member Author

@alanshaw you are right! https://github.com/daviddias/daviddias.me/blob/master/Makefile#L40

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
exp/expert Having worked on the specific codebase is important help wanted Seeking public contribution on this issue kind/bug A bug in existing code (including security flaws) P2 Medium: Good to have, but can wait until someone steps up
Projects
None yet
Development

No branches or pull requests

3 participants