UNPKG

update-banner

Version:

Update the banner comment in a string of javascript.

98 lines (62 loc) 3.42 kB
# update-banner [![NPM version](https://img.shields.io/npm/v/update-banner.svg?style=flat)](https://www.npmjs.com/package/update-banner) [![NPM monthly downloads](https://img.shields.io/npm/dm/update-banner.svg?style=flat)](https://npmjs.org/package/update-banner) [![NPM total downloads](https://img.shields.io/npm/dt/update-banner.svg?style=flat)](https://npmjs.org/package/update-banner) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/update-banner.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/update-banner) > Update the banner comment in a string of javascript. ## Install Install with [npm](https://www.npmjs.com/): ```sh $ npm install --save update-banner ``` ## Usage In existing banners, copyright statements are updated using [update-copyright](https://github.com/jonschlinkert/update-copyright). If the string does not have a banner one will be added using a [template](#options.template). ```js var banner = require('update-banner'); var str = fs.readFileSync('index.js', 'utf8'); banner(str); ``` Pass a custom template and/or data: ```js var copyright = 'Copyright (c) 2015, Jon Schlinkert.'; console.log(banner('/* <%= copyright %> */\n', { copyright: copyright })); //=> '/* Copyright (c) 2015, Jon Schlinkert. */\n' ``` ## Options ### options.template Customize the [template](lib/template.js) to use for creating a banner. **Example** This is the default template ```js /*! * <%= name %> <<%= repository %>> * * <%= copyright %> * Released under the <%= license %> License. */ ``` ## About ### Related projects * [extract-banner](https://www.npmjs.com/package/extract-banner): Extract a banner comment from a string of javascript. | [homepage](https://github.com/jonschlinkert/extract-banner "Extract a banner comment from a string of javascript.") * [strip-banner](https://www.npmjs.com/package/strip-banner): Strip banners from code. | [homepage](https://github.com/jonschlinkert/strip-banner "Strip banners from code.") * [update-copyright](https://www.npmjs.com/package/update-copyright): Update a copyright statement with the current year. Also makes minor corrections. | [homepage](https://github.com/jonschlinkert/update-copyright "Update a copyright statement with the current year. Also makes minor corrections.") ### Contributing Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). ### Building docs _(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_ To generate the readme, run the following command: ```sh $ npm install -g verbose/verb#dev verb-generate-readme && verb ``` ### Running tests Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command: ```sh $ npm install && npm test ``` ### Author **Jon Schlinkert** * [github/jonschlinkert](https://github.com/jonschlinkert) * [twitter/jonschlinkert](https://twitter.com/jonschlinkert) ### License Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert). MIT *** _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.4.2, on February 01, 2017._