17 lines
514 B
JavaScript
17 lines
514 B
JavaScript
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", {
|
|
value: true
|
|
});
|
|
exports.addCommentBefore = addCommentBefore;
|
|
exports.default = addComment;
|
|
|
|
function addCommentBefore(str, indent, comment) {
|
|
if (!comment) return str;
|
|
const cc = comment.replace(/[\s\S]^/gm, `$&${indent}#`);
|
|
return `#${cc}\n${indent}${str}`;
|
|
}
|
|
|
|
function addComment(str, indent, comment) {
|
|
return !comment ? str : comment.indexOf('\n') === -1 ? `${str} #${comment}` : `${str}\n` + comment.replace(/^/gm, `${indent || ''}#`);
|
|
} |