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

Commit

Permalink
feat: add --hidden flag to cli add command (#2649)
Browse files Browse the repository at this point in the history
* feat: add --hidden flag to cli add command

* fix: update folder hash on get-recursively cli test

* fix: increase bundle max size
  • Loading branch information
Pedro Santos authored and achingbrain committed Dec 10, 2019
1 parent 7a87d8f commit ed886f4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .aegir.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const preloadNode = MockPreloadNode.createNode()
const echoServer = EchoServer.createServer()

module.exports = {
bundlesize: { maxSize: '650kB' },
bundlesize: { maxSize: '651kB' },
webpack: {
resolve: {
mainFields: ['browser', 'main'],
Expand Down
8 changes: 7 additions & 1 deletion src/cli/commands/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ module.exports = {
type: 'boolean',
default: true,
describe: 'Preload this object when adding'
},
hidden: {
alias: 'H',
type: 'boolean',
default: false,
describe: 'Include files that are hidden. Only takes effect on recursive add.'
}
},

Expand Down Expand Up @@ -153,7 +159,7 @@ module.exports = {
}

const source = argv.file
? globSource(argv.file, { recursive: argv.recursive })
? globSource(argv.file, { recursive: argv.recursive, hidden: argv.hidden })
: process.stdin // Pipe directly to ipfs.add

let finalHash
Expand Down
13 changes: 10 additions & 3 deletions test/cli/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ describe('files', () => runOnAndOff((thing) => {
expect(out).to.equal(recursiveGetDirResults.join('\n') + '\n')
})

it('add recursively including hidden files', async function () {
this.timeout(60 * 1000)

const out = await ipfs('add -r -H test/fixtures/test-data/recursive-get-dir')
expect(out).to.include('added QmdBd5zgdJQHsyaaAm9Vnth7NWwj23gj3Ew17r6bTvVkch recursive-get-dir/.hidden.txt')
})

it('add directory with trailing slash test', async function () {
this.timeout(30 * 1000)

Expand Down Expand Up @@ -410,12 +417,12 @@ describe('files', () => runOnAndOff((thing) => {
it('get recursively', async function () {
this.timeout(20 * 1000)

const outDir = path.join(process.cwd(), 'Qmaj2NmcyAXT8dFmZRRytE12wpcaHADzbChKToMEjBsj5Z')
const outDir = path.join(process.cwd(), 'QmTCaAvZ5dquoa2jrgTRa3gn9n4Ymrz8mEdePP8jiaTvf9')
rimraf(outDir)

const out = await ipfs('get Qmaj2NmcyAXT8dFmZRRytE12wpcaHADzbChKToMEjBsj5Z')
const out = await ipfs('get QmTCaAvZ5dquoa2jrgTRa3gn9n4Ymrz8mEdePP8jiaTvf9')
expect(out).to.eql(
'Saving file(s) Qmaj2NmcyAXT8dFmZRRytE12wpcaHADzbChKToMEjBsj5Z\n'
'Saving file(s) QmTCaAvZ5dquoa2jrgTRa3gn9n4Ymrz8mEdePP8jiaTvf9\n'
)

const expectedDir = path.join(process.cwd(), 'test', 'fixtures', 'test-data', 'recursive-get-dir')
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/test-data/recursive-get-dir/.hidden.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This file is hidden!

0 comments on commit ed886f4

Please sign in to comment.