Skip to content

Commit

Permalink
Make import options optional.
Browse files Browse the repository at this point in the history
  • Loading branch information
saul-jb committed Mar 26, 2024
1 parent 94dd188 commit 98682a2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 19 deletions.
6 changes: 2 additions & 4 deletions packages/fs-exporter/test/export.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ describe('exporter', () => {
for (const data of testData.data) {
const [{ cid }] = await all(importer(
blockstore,
data.path,
{}
data.path
))

const exportPath = data.generatePath(outPath)
Expand All @@ -42,8 +41,7 @@ describe('exporter', () => {
it('exports a directory ', async () => {
const results = await all(importer(
blockstore,
testData.root,
{}
testData.root
))

assert.equal(results.length, testData.data.length)
Expand Down
2 changes: 1 addition & 1 deletion packages/fs-importer/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const selectChunker = selectChunkerFunc
// export const importPlaintext = importPlaintextFunc
// export const importEncrypted = importEncryptedFunc

export const importer = async function * (blockstore: Blockstore, path: string, options: AddOptions): AsyncIterable<ImportResult & { path: string }> {
export const importer = async function * (blockstore: Blockstore, path: string, options: AddOptions = {}): AsyncIterable<ImportResult & { path: string }> {
const ufs = unixfs({ blockstore })

const stat = await fs.lstat(path)
Expand Down
17 changes: 3 additions & 14 deletions packages/fs-importer/test/import.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,16 @@ import assert from 'assert/strict'
import * as testData from '@organicdesign/db-test-data'
import { BlackHoleBlockstore } from 'blockstore-core/black-hole'
import all from 'it-all'
import { importer, selectChunker, selectHasher } from '../src/index.js'
import { importer } from '../src/index.js'

const blockstore = new BlackHoleBlockstore()

const importerConfig = {
chunker: selectChunker(),
hasher: selectHasher(),
cidVersion: 1
} as const

describe('importer', () => {
it('imports files ', async () => {
for (const data of testData.data) {
const [result] = await all(importer(
blockstore,
data.path,
importerConfig
data.path
))

const dataFile = testData.getDataFile(result.path)
Expand All @@ -31,11 +24,7 @@ describe('importer', () => {
})

it('imports a directory ', async () => {
const results = await all(importer(
blockstore,
testData.root,
importerConfig
))
const results = await all(importer(blockstore, testData.root))

assert.equal(results.length, testData.data.length)

Expand Down

0 comments on commit 98682a2

Please sign in to comment.