-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(util): exportText treat text as template string #195
Conversation
return `exports['${name}'] = \`${withNewLines}\`\n` | ||
// jsesc replace "\n" with "\\n" | ||
// https://github.com/mathiasbynens/jsesc/issues/20 | ||
const serialized = value.split('\n').map(line => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jsesc does replace \\n
with \n
.
it('does escape template variable on the text', () => { | ||
/* eslint-disable no-template-curly-in-string */ | ||
const formatted = exportText('name', '`${1}`') | ||
const expected = "exports['name'] = `\n\\`\\${1}\\`\n`\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also test following code is work.
var exports = {};
eval("exports['name'] = `\n\\`\\${1}\\`\n`\n")
escape text by jsesc
9ffb7c7
to
7c404c5
Compare
/cc @bahmutov @krzkaczor |
This PR looks good, it would be nice to see it merged, so I can strip out my workarounds. |
🎉 This PR is included in version 7.1.13 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
escape text by jsesc.
jsesc
supportquote: "backtick"
.fix #117