@mongosh/js-multiline-to-singleline
Advanced tools
Comparing version 1.6.0 to 1.6.1
@@ -60,2 +60,21 @@ "use strict"; | ||
} | ||
function multilineTemplateStringToSingleLine({ types: t }) { | ||
return { | ||
visitor: { | ||
TemplateLiteral(path) { | ||
var _a, _b; | ||
if (!path.node.quasis.some(({ value }) => value.raw.match(/[\r\n]/))) { | ||
return; | ||
} | ||
if (path.parentPath.isTaggedTemplateExpression()) { | ||
path.parentPath.replaceWith(t.callExpression(t.identifier('eval'), [t.stringLiteral(this.file.code.slice((_a = path.parent.start) !== null && _a !== void 0 ? _a : undefined, (_b = path.parent.end) !== null && _b !== void 0 ? _b : undefined))])); | ||
return; | ||
} | ||
path.replaceWith(t.templateLiteral(path.node.quasis.map(el => t.templateElement({ | ||
raw: el.value.raw.replace(/\n|\r\n?/g, '\\n') | ||
}, el.tail)), path.node.expressions)); | ||
} | ||
} | ||
}; | ||
} | ||
function makeMultilineJSIntoSingleLine(src) { | ||
@@ -73,3 +92,3 @@ var _a, _b; | ||
browserslistConfigFile: false, | ||
plugins: [lineCommentToBlockComment], | ||
plugins: [lineCommentToBlockComment, multilineTemplateStringToSingleLine], | ||
sourceType: 'script' | ||
@@ -76,0 +95,0 @@ })) === null || _a === void 0 ? void 0 : _a.code) !== null && _b !== void 0 ? _b : src; |
{ | ||
"name": "@mongosh/js-multiline-to-singleline", | ||
"version": "1.6.0", | ||
"version": "1.6.1", | ||
"description": "Make multiline JS into a single line", | ||
@@ -37,3 +37,3 @@ "main": "./lib/index.js", | ||
}, | ||
"gitHead": "fbbf54a08fb315ae5fde693a98d439b9aa3285f8" | ||
"gitHead": "51c067456d3e0127156ef1722a44659151e01a12" | ||
} |
Sorry, the diff of this file is not supported yet
19786
114