@leny/banye
v0.4.0
Published
Add dynamic header comments to files - cleaned/updated version of misteroneill/bannerize
Maintainers
Readme
@leny/banye
Add dynamic header comments to files - cleaned/updated version of misteroneill/bannerize
Banner Templates
Banner templates use the EJS templating language. Templates are passed the following properties:
pkg: A representation of the nearestpackage.jsonfile.date: A JavaScript Date object.path: Relate path of the file.
A simple banner might look something like:
/*! <%= pkg.name %> | <%= pkg.version %>
* (c) <%= date.getFullYear() %>
*/And render to:
/*! @leny/banye | 1.0.0
* (c) 2021 MIT
*/CLI
banye ships with a CLI command. Its options vary from the programmatic API. To see all its options, use:
$ banye --helpAn example usage might look like:
$ banye *.js *.css --banner=foo/bar.ejsAPI
The banye module can be used in your programs. It exports a single function, banye , which takes two arguments:
banye(patterns, [options])
pattern{String|Array}: A string or array of glob pattern(s) to which to apply the banner.[options]{Object}: An object containing optional values.
The return value of bannerize() is a Promise that resolves with an array of all the file paths it modified.
Options
bannerA banner file location. Defaults tobanner.ejsin thecwd.cwdOverride thecwdfor all paths passed tobannerize. Relative paths will be relative toprocess.cwd(). Defaults toprocess.cwd().lineBreakSets the linebreak ('CRLF','LF'). Defaults to'LF'.replaceReplace the starting lines of the files (up to the first empty line) with the bannercheckCheck if header already exists in good format before add or replace
