-
-
Notifications
You must be signed in to change notification settings - Fork 247
Closed
Description
After upgrading from version 8 to 9, some of my multi-line formatted commands have broken.
Reproduction:
import {$} from "execa";
try {
// 404 is just a stupid way to get an error for some details.
// Some commands are large, so I break them up by escaping newlines in templates:
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#multi-line_strings
await $`404 abc\
def`;
} catch (error) {
console.log("command", error.command); // 404 abc ef
console.log("escaped", error.escapedCommand); // 404 "abc " ef
}Expected command: 404 abc def or something close enough
Actual commands: 404 abc ef or 404 "abc " ef
I suspect it may be related to the difference between the template strings and the raw strings passed to a tag function. Example:
function poo(foo, ...bar) {
console.log("strings", foo.slice());
console.log("raw", foo.raw);
}
poo`404 abc def`;
poo`404 abc
def`;
poo`404 abc\
def`;In the first two examples, the raw strings and the strings arrays match up.
strings (1) ['404 abc def']
raw (1) ['404 abc def']
strings (1) ['404 abc
def']
raw (1) ['404 abc
def']
In the 3rd sample however the generated strings and the raw strings are different.
strings (1) ['404 abc def']
raw (1) ['404 abc\\
def']
I suspect there may be some code that may be mixing up the raw strings with the regular strings causing some of the escaping to be offset by a character. But that is just a theory 🤷.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels