npm

Join us for the upcoming webinar, "Enterprise JavaScript done right: the tools you love, the security you need."Sign up here »

o7

1.1.0 • Public • Published

o7

tiny file processor

Installation

npm i o7

Usage

const o7 = require('o7')
 
function middleware (files) {
  files.map(file => file.contents.concat('\nhello!'))
}
 
o7([middleware], 'destination/').then(() => {
  // success!
})

o7(Array(MIDDLEWARE), DESTINATION, [OPTIONS]) -> Promise

Takes an array of middleware functions that each receive a files argument, which is an array of vfiles. Middleware functions don't need to return anything, they can modify the files array in-place. Middleware runs in the order it's defined in.

DESTINATION can be an absolute or relative path to where the modified files should be outputted to.

OPTIONS is an optional object that can have two keys:

  • source: Where to read files from. Default is process.cwd()
  • exclude: An array of files or directories to exclude. Must be strings.
  • noRead: Doesn't read from disk, provides an empty files array instead.
  • noWrite: Doesn't write to disk.

Returns a promise with the processed files as its argument when finished writing.

License

AGPL 3.0 (see LICENSE)

Keywords

none

install

npm i o7

Downloadsweekly downloads

10

version

1.1.0

license

AGPL-3.0+

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability