From 23558917ef4869634ad78052ef97dfe28063c700 Mon Sep 17 00:00:00 2001 From: Mickael Jeanroy Date: Mon, 20 Feb 2017 13:17:09 +0100 Subject: [PATCH] refactor: use commenting package to generate block comment --- package.json | 3 ++- src/generate-block-comment.js | 12 ++---------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 8427bed9..9cbe1292 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/generate-block-comment.js b/src/generate-block-comment.js index a735e214..682da45b 100644 --- a/src/generate-block-comment.js +++ b/src/generate-block-comment.js @@ -22,8 +22,7 @@ * SOFTWARE. */ -const _ = require('lodash'); -const EOL = require('./eol.js'); +const commenting = require('commenting'); /** * Generate block comment from given text content. @@ -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'}); };