Use join in replaceNewlinesWithLiterallines (#10860)

This commit is contained in:
fisker Cheung authored and GitHub committed 2021-05-16 12:40:00 +08:00
1 parent a9c3960f2f
commit 213a825131
1 file changed
+2 -2
+2 -2
View File
@@ -1,6 +1,6 @@
"use strict";
const getLast = require("../utils/get-last");
const { literalline } = require("./doc-builders");
const { literalline, join } = require("./doc-builders");
const isConcat = (doc) => Array.isArray(doc) || (doc && doc.type === "concat");
const getDocParts = (doc) => {
@@ -390,7 +390,7 @@ function normalizeDoc(doc) {
function replaceNewlinesWithLiterallines(doc) {
return mapDoc(doc, (currentDoc) =>
typeof currentDoc === "string" && currentDoc.includes("\n")
? currentDoc.split(/(\n)/).map((v, i) => (i % 2 === 0 ? v : literalline))
? join(literalline, currentDoc.split("\n"))
: currentDoc
);
}