feat: ability to add banner (#20)

Lets you add a custom banner.

```sh
create-index src -u --banner "/* eslint-disable */"
```
```js
/* eslint-disable */

// @create-index

import xxx ...
```
This commit is contained in:
laggingreflex
2016-11-29 17:45:23 +00:00
committed by Gajus Kuizinas
parent d7e2528999
commit fdb17d0179
4 changed files with 26 additions and 4 deletions
+14 -2
View File
@@ -22,10 +22,22 @@ const buildExportBlock = (files) => {
return importBlock;
};
export default (filePaths) => {
export default (filePaths, options = {}) => {
let code;
code = '// @create-index\n\n';
code = '';
if (options.banner) {
const banners = _.isArray(options.banner) ? options.banner : [options.banner];
banners.forEach((banner) => {
code += banner + '\n';
});
code += '\n';
}
code += '// @create-index\n\n';
if (filePaths.length) {
const sortedFilePaths = filePaths.sort();