Skip to content

Commit

Permalink
Fix windows line ending on template literals (#1439)
Browse files Browse the repository at this point in the history
Fixes #1432
  • Loading branch information
vjeux committed May 1, 2017
1 parent e392093 commit 4b7d265
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/printer.js
Expand Up @@ -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");

Expand Down
19 changes: 19 additions & 0 deletions tests/windows/__snapshots__/jsfmt.spec.js.snap
Expand Up @@ -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
\`;
`;
7 changes: 7 additions & 0 deletions tests/windows/template.js
@@ -0,0 +1,7 @@
const aLongString = `
Line 1
Line 2
Line 3
Line 4
Line 5
`;

0 comments on commit 4b7d265

Please sign in to comment.