From 379f48032e7370b56abb10fcbbbcab88c9db5b29 Mon Sep 17 00:00:00 2001 From: Arnold Daniels Date: Fri, 17 Mar 2023 10:51:21 -0400 Subject: [PATCH 1/2] fix example in README of ipfs-unixfs-importer * import `fs` * remove undefined variables: `file`, `file2`, and `options` * fix typo causing error "no such file or directory, open './foo/quxx'" --- packages/ipfs-unixfs-importer/README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/ipfs-unixfs-importer/README.md b/packages/ipfs-unixfs-importer/README.md index e76fed1a..f288d32e 100644 --- a/packages/ipfs-unixfs-importer/README.md +++ b/packages/ipfs-unixfs-importer/README.md @@ -44,7 +44,7 @@ Let's create a little directory to import: > cd /tmp > mkdir foo > echo 'hello' > foo/bar -> echo 'world' > foo/quux +> echo 'world' > foo/quxx ``` And write the importing logic: @@ -52,20 +52,21 @@ And write the importing logic: ```js import { importer } from 'ipfs-unixfs-importer' import { MemoryBlockstore } from 'blockstore-core/memory' +import * as fs from 'fs' // Where the blocks will be stored const blockstore = new MemoryBlockstore() -// Import path /tmp/foo/bar +// Import path /tmp/foo/ const source = [{ path: '/tmp/foo/bar', - content: fs.createReadStream(file) + content: fs.createReadStream('/tmp/foo/bar') }, { path: '/tmp/foo/quxx', - content: fs.createReadStream(file2) + content: fs.createReadStream('/tmp/foo/quxx') }] -for await (const entry of importer(source, blockstore, options)) { +for await (const entry of importer(source, blockstore)) { console.info(entry) } ``` From ac38f0b783c42f40005493debb39504cea829bd6 Mon Sep 17 00:00:00 2001 From: Alex Potsides Date: Thu, 23 Mar 2023 11:21:09 +0000 Subject: [PATCH 2/2] chore: Apply suggestions from code review --- packages/ipfs-unixfs-importer/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/ipfs-unixfs-importer/README.md b/packages/ipfs-unixfs-importer/README.md index f288d32e..9eb326d9 100644 --- a/packages/ipfs-unixfs-importer/README.md +++ b/packages/ipfs-unixfs-importer/README.md @@ -44,7 +44,7 @@ Let's create a little directory to import: > cd /tmp > mkdir foo > echo 'hello' > foo/bar -> echo 'world' > foo/quxx +> echo 'world' > foo/quux ``` And write the importing logic: @@ -52,7 +52,7 @@ And write the importing logic: ```js import { importer } from 'ipfs-unixfs-importer' import { MemoryBlockstore } from 'blockstore-core/memory' -import * as fs from 'fs' +import * as fs from 'node:fs' // Where the blocks will be stored const blockstore = new MemoryBlockstore() @@ -63,7 +63,7 @@ const source = [{ content: fs.createReadStream('/tmp/foo/bar') }, { path: '/tmp/foo/quxx', - content: fs.createReadStream('/tmp/foo/quxx') + content: fs.createReadStream('/tmp/foo/quux') }] for await (const entry of importer(source, blockstore)) {