Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/leny/banye
Last synced: 7 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/leny/banye
- Owner: leny
- Created: 2021-02-28T10:04:14.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-04-20T09:12:12.000Z (over 3 years ago)
- Last Synced: 2024-08-08T15:44:45.020Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 50.8 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# @leny/banye
> Add dynamic header comments to files - cleaned/updated version of [misteroneill/bannerize](https://github.com/misteroneill/bannerize)
* * *
## Banner Templates
Banner templates use the [EJS](https://www.npmjs.com/package/ejs) templating language. Templates are passed the following properties:
- `pkg`: A representation of the nearest `package.json` file.
- `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:
```sh
$ banye --help
```An example usage might look like:
```sh
$ banye *.js *.css --banner=foo/bar.ejs
```## API
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
- `banner` A banner file location. Defaults to `banner.ejs` in the `cwd`.
- `cwd` Override the `cwd` for all paths passed to `bannerize`. Relative paths will be relative to `process.cwd()`. Defaults to `process.cwd()`.
- `lineBreak` Sets the linebreak (`'CRLF'`, `'LF'`). Defaults to `'LF'`.- `replace` Replace the starting lines of the files (up to the first empty line) with the banner
- `check` Check if header already exists in good format before add or replace