Skip to content

Commit

Permalink
refactor: use commenting package to generate block comment
Browse files Browse the repository at this point in the history
  • Loading branch information
mjeanroy committed Feb 20, 2017
1 parent 294c475 commit 2355891
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -25,9 +25,10 @@
},
"repository": {
"type": "git",
"url" : "https://github.com/mjeanroy/rollup-plugin-license"
"url": "https://github.com/mjeanroy/rollup-plugin-license"
},
"dependencies": {
"commenting": "1.0.3",
"lodash": "4.17.2",
"magic-string": "0.17.0",
"mkdirp": "0.5.1",
Expand Down
12 changes: 2 additions & 10 deletions src/generate-block-comment.js
Expand Up @@ -22,8 +22,7 @@
* SOFTWARE.
*/

const _ = require('lodash');
const EOL = require('./eol.js');
const commenting = require('commenting');

/**
* Generate block comment from given text content.
Expand All @@ -32,12 +31,5 @@ const EOL = require('./eol.js');
* @return {string} Block comment.
*/
module.exports = function generateBlockComment(text) {
const bannerContent = _.chain(text)
.trim()
.split(EOL)
.map((line) => _.trimEnd(` * ${line}`))
.join(EOL)
.value();

return `/**${EOL}${bannerContent}${EOL} */${EOL}`;
return commenting(text.trim(), {extension: '.js'});
};

0 comments on commit 2355891

Please sign in to comment.