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

Commit ed886f4

Browse files
Pedro Santosachingbrain
Pedro Santos
authored andcommitted
feat: add --hidden flag to cli add command (#2649)
* feat: add --hidden flag to cli add command * fix: update folder hash on get-recursively cli test * fix: increase bundle max size
1 parent 7a87d8f commit ed886f4

File tree

4 files changed

+19
-5
lines changed

4 files changed

+19
-5
lines changed

.aegir.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const preloadNode = MockPreloadNode.createNode()
99
const echoServer = EchoServer.createServer()
1010

1111
module.exports = {
12-
bundlesize: { maxSize: '650kB' },
12+
bundlesize: { maxSize: '651kB' },
1313
webpack: {
1414
resolve: {
1515
mainFields: ['browser', 'main'],

src/cli/commands/add.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ module.exports = {
106106
type: 'boolean',
107107
default: true,
108108
describe: 'Preload this object when adding'
109+
},
110+
hidden: {
111+
alias: 'H',
112+
type: 'boolean',
113+
default: false,
114+
describe: 'Include files that are hidden. Only takes effect on recursive add.'
109115
}
110116
},
111117

@@ -153,7 +159,7 @@ module.exports = {
153159
}
154160

155161
const source = argv.file
156-
? globSource(argv.file, { recursive: argv.recursive })
162+
? globSource(argv.file, { recursive: argv.recursive, hidden: argv.hidden })
157163
: process.stdin // Pipe directly to ipfs.add
158164

159165
let finalHash

test/cli/files.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,13 @@ describe('files', () => runOnAndOff((thing) => {
165165
expect(out).to.equal(recursiveGetDirResults.join('\n') + '\n')
166166
})
167167

168+
it('add recursively including hidden files', async function () {
169+
this.timeout(60 * 1000)
170+
171+
const out = await ipfs('add -r -H test/fixtures/test-data/recursive-get-dir')
172+
expect(out).to.include('added QmdBd5zgdJQHsyaaAm9Vnth7NWwj23gj3Ew17r6bTvVkch recursive-get-dir/.hidden.txt')
173+
})
174+
168175
it('add directory with trailing slash test', async function () {
169176
this.timeout(30 * 1000)
170177

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

413-
const outDir = path.join(process.cwd(), 'Qmaj2NmcyAXT8dFmZRRytE12wpcaHADzbChKToMEjBsj5Z')
420+
const outDir = path.join(process.cwd(), 'QmTCaAvZ5dquoa2jrgTRa3gn9n4Ymrz8mEdePP8jiaTvf9')
414421
rimraf(outDir)
415422

416-
const out = await ipfs('get Qmaj2NmcyAXT8dFmZRRytE12wpcaHADzbChKToMEjBsj5Z')
423+
const out = await ipfs('get QmTCaAvZ5dquoa2jrgTRa3gn9n4Ymrz8mEdePP8jiaTvf9')
417424
expect(out).to.eql(
418-
'Saving file(s) Qmaj2NmcyAXT8dFmZRRytE12wpcaHADzbChKToMEjBsj5Z\n'
425+
'Saving file(s) QmTCaAvZ5dquoa2jrgTRa3gn9n4Ymrz8mEdePP8jiaTvf9\n'
419426
)
420427

421428
const expectedDir = path.join(process.cwd(), 'test', 'fixtures', 'test-data', 'recursive-get-dir')
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This file is hidden!

0 commit comments

Comments
 (0)