(str)
| 1 | import stripAnsi from "strip-ansi"; |
| 2 | |
| 3 | export function removeCWD(str) { |
| 4 | const isWin = process.platform === "win32"; |
| 5 | let cwd = process.cwd(); |
| 6 | |
| 7 | if (isWin) { |
| 8 | if (str.split("\n").length > 3) { |
| 9 | // @import '\ |
| 10 | // \ |
| 11 | // \ |
| 12 | // '; |
| 13 | |
| 14 | return stripAnsi(str) |
| 15 | .replace(/\(from .*?\)/, "(from `replaced original path`)") |
| 16 | .replace(new RegExp(cwd, "g"), ""); |
| 17 | } |
| 18 | |
| 19 | // eslint-disable-next-line no-param-reassign |
| 20 | str = str.replace(/\\/g, "/"); |
| 21 | // eslint-disable-next-line no-param-reassign |
| 22 | cwd = cwd.replace(/\\/g, "/"); |
| 23 | } |
| 24 | |
| 25 | return stripAnsi(str) |
| 26 | .replace(/\(from .*?\)/, "(from `replaced original path`)") |
| 27 | .replace(new RegExp(cwd, "g"), ""); |
| 28 | } |
| 29 | |
| 30 | export default (errors, shortError, type) => |
| 31 | errors.map((error) => { |
no outgoing calls
no test coverage detected
searching dependent graphs…