Fix windows line ending on template literals (#1439)

Fixes #1432
master
Christopher Chedeau 2017-05-01 14:39:03 -07:00 committed by GitHub
parent e39209386c
commit 4b7d265000
3 changed files with 27 additions and 1 deletions

View File

@ -1513,7 +1513,7 @@ function genericPrintNoParens(path, options, print, args) {
parts.push(concat(printClass(path, options, print)));
return concat(parts);
case "TemplateElement":
return join(literalline, n.value.raw.split("\n"));
return join(literalline, n.value.raw.split(/\r?\n/g));
case "TemplateLiteral":
var expressions = path.map(print, "expressions");

View File

@ -14,3 +14,22 @@ line;
endings;
`;
exports[`template.js 1`] = `
const aLongString = \`
Line 1
Line 2
Line 3
Line 4
Line 5
\`;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const aLongString = \`
Line 1
Line 2
Line 3
Line 4
Line 5
\`;
`;

View File

@ -0,0 +1,7 @@
const aLongString = `
Line 1
Line 2
Line 3
Line 4
Line 5
`;