(link: string, target: string, cause: unknown)
| 174 | } |
| 175 | |
| 176 | function linkWriteError(link: string, target: string, cause: unknown): Error { |
| 177 | const code = (cause as NodeJS.ErrnoException | undefined)?.code; |
| 178 | const why = code === 'ENOENT' ? 'its folder does not exist' |
| 179 | : code === 'EACCES' || code === 'EROFS' ? 'it is read-only' |
| 180 | : code === 'EPERM' || code === 'EBUSY' ? 'it is read-only or in use' |
| 181 | : cause instanceof Error ? cause.message : String(cause); |
| 182 | const message = target === link |
| 183 | ? `${link} is a symbolic link that can't be followed (${why}).` |
| 184 | : `${link} is a symbolic link to ${target}, which can't be written (${why}).`; |
| 185 | return Object.assign( |
| 186 | new Error(`${message} CodeGraph writes through links and never replaces one with a copy: fix the link or make its file writable, then run this again.`, { cause }), |
| 187 | { code }, |
| 188 | ); |
| 189 | } |
| 190 | |
| 191 | /** |
| 192 | * Delete a file that codegraph's change left with nothing of the user's in |
no outgoing calls
no test coverage detected