Home

Awesome

deprecated

More info on active projects and modules at dat-ecosystem.org <img src="https://i.imgur.com/qZWlO1y.jpg" width="30" height="30" />


hyperdrive-import-files

Import the contents of a folder into a hyperdrive, and optionally keep watching for changes.

Build Status

Example

const hyperdrive = require('hyperdrive')
const memdb = require('memdb')
const hyperImport = require('hyperdrive-import-files')

const drive = hyperdrive(memdb())
const archive = drive.createArchive()

hyperImport(archive, 'a/directory/', err => {
  // ...
})

Installation

$ npm install hyperdrive-import-files

API

hyperImport(archive, target, [, options][, cb])

Recursively import target, which is the path to a directory or file, into archive and call cb with the potential error. The import happens sequentually. Returns a status object.

Options

To enable watching, set watch: true, like this:

const status = hyperImport(archive, target, { watch: true }, err => {
  console.log('initial import done')
})
status.on('error', err => {
  // ...
})
// when you want to quit:
status.close()

If you want to import into a subfolder, set basePath:

hyperImport(archive, target, { basePath: '/some/subdir' }, err => {...})

status

Events:

Properties:

License

MIT