Closed Maxim-Mazurok closed 1 year ago
Here's a reproduction:
const DEFAULT_INDENT = " ";
const INDENT_REGEXP = /^(\s+)[^\s]/m;
function detectIndent(text) {
try {
return INDENT_REGEXP.exec(text)[1] || DEFAULT_INDENT;
} catch (e) {
/* c8 ignore next 2 */
return DEFAULT_INDENT;
}
}
const text = `{\r\n \"name\": \"my-project\",\r\n`;
console.log(JSON.stringify(detectIndent(text)));
will print "\n "
As you can see, it includes \n
into the detected indentation.
The problem is with this function: https://github1s.com/browserslist/update-db/blob/HEAD/index.js#L10-L17
My colleague and I would like to take on this issue if that's ok
After the first run of
npx -y update-browserslist-db@latest
in our project, it messed uppackage-lock.json
formatting, see:This is on my colleague's PC (windows, I believe)
This is on my PC (Ubuntu, WSL2):![image](https://user-images.githubusercontent.com/7756211/189571818-83dcda87-0db5-4cbc-be0b-89ea8c2db71d.png)
This is my output:
After that, I changed nothing re-running the command worked just fine. Can't reproduce anymore.