diff --git a/dist/index1.js b/dist/index1.js index 92c1a41c..b5cb1ee2 100755 --- a/dist/index1.js +++ b/dist/index1.js @@ -27398,7 +27398,8 @@ class OutputListener { get contents () { return this._buff .map(chunk => chunk.toString()) - .join(''); + .join('') + .replace(/`/g, '\\`'); } } diff --git a/wrapper/lib/output-listener.js b/wrapper/lib/output-listener.js index 9686dbae..993ee45d 100644 --- a/wrapper/lib/output-listener.js +++ b/wrapper/lib/output-listener.js @@ -34,7 +34,8 @@ class OutputListener { get contents () { return this._buff .map(chunk => chunk.toString()) - .join(''); + .join('') + .replace(/`/g, '\\`'); } } diff --git a/wrapper/test/output-listener.test.js b/wrapper/test/output-listener.test.js index 229c3cf0..7394c855 100644 --- a/wrapper/test/output-listener.test.js +++ b/wrapper/test/output-listener.test.js @@ -14,4 +14,13 @@ describe('output-listener', () => { listen(Buffer.from('baz')); expect(listener.contents).toEqual('foobarbaz'); }); + + it('escape backticks', () => { + const listener = new OutputListener(); + const listen = listener.listener; + listen(Buffer.from('foo')); + listen(Buffer.from('`bar`')); + listen(Buffer.from('baz')); + expect(listener.contents).toEqual('foo\\`bar\\`baz'); + }); });