Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.
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
6 changes: 5 additions & 1 deletion packages/ipfs/src/cli/commands/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,11 @@ module.exports = {
mode: argv.mode,
mtime
})
: getStdin() // Pipe directly to ipfs.add
: {
content: getStdin(),
mode: argv.mode,
mtime
} // Pipe to ipfs.add tagging with mode and mtime

let finalCid

Expand Down
26 changes: 25 additions & 1 deletion packages/ipfs/test/cli/files-regular.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,9 @@ describe('files', () => {
it('add from pipe', async () => {
const cid = new CID('QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB')

ipfs.add.withArgs(matchIterable(), defaultAddArgs()).returns([{
ipfs.add.withArgs(sinon.match({
content: matchIterable()
}), defaultAddArgs()).returns([{
cid,
path: 'readme'
}])
Expand All @@ -173,6 +175,28 @@ describe('files', () => {
expect(out).to.equal(`added ${cid} ${cid}\n`)
})

it('add from pipe with mtime=100', async () => {
const cid = new CID('QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB')

ipfs.add.withArgs(sinon.match({
content: matchIterable(),
mtime: { secs: 100 }
}), defaultAddArgs()).returns([{
cid,
path: 'readme'
}])

const proc = cli('add --mtime=100', {
ipfs,
getStdin: function * () {
yield Buffer.from('hello\n')
}
})

const out = await proc
expect(out).to.equal(`added ${cid} ${cid}\n`)
})

it('add --quiet', async () => {
const cid = new CID('QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB')

Expand Down