vinyl-adapter-picker

Protocol based vinyl adapter picker.

Usage no npm install needed!

<script type="module">
  import vinylAdapterPicker from 'https://cdn.skypack.dev/vinyl-adapter-picker';
</script>

README

vinyl-adapter-picker

Protocol based vinyl adapter picker.

travis codecov

vinyl-adapter-picker lets you register vinyl adapters and use them depending on the protocol part of globs.

Install

npm install --save vinyl-adapter-picker

Usage

const vp = require('vinyl-adapter-picker')
const vfs = require('vinyl-fs')
const vhttp = require('vinyl-http')

// add default adapter
vp.add(null, vfs)
// add `http` adapter
vp.add('http', vfs)

// push local files to remote
vp.src('dist/*')
  .pipe(vp.dest('http://example.org/'))

API

add(protocol, adapter)

Register an adapter for the given protocol. It will then be available via src and dest.

protocol {string|null}

Protocol to associate the adapter with. It must be the protocol part of a standard uri.

If null is specified, it registers a default adapter that will be used if a glob does not contain any protocol part (i.e *.txt, ./*.txt).

adapter {object}

Adapter that must provide src and dest functions.

Example

const vfs = require('vinyl-fs')

// explicit protocol
vp.add('file', vfs)
vp.src('file://*.txt')

// default protocol
vp.add(null, vfs)
vp.src('*.txt')

remove(protocol)

Remove the associated adapter.

protocol {string|null}

Protocol for which the associated adapter is removed.

src(globs[, options]) and dest(globs[, options])

Return a stream of vinyl File objects.

globs {string|array}

globs that are used to create the stream. Given the protocol part of each glob, the appropriate adapter is used.

options {object}

Options passed to underlying adapter.

License

MIT © Nicolas Gryman