chore(gomod): better update failure logging

This commit is contained in:
Rhys Arkins 2023-08-24 19:36:03 +02:00
parent 53e3deb7d9
commit acdd430caf
No known key found for this signature in database
GPG key ID: 4B50341A77CC799B

View file

@ -28,6 +28,11 @@ export function updateDependency({
} }
const depNameNoVersion = getDepNameWithNoVersion(depName); const depNameNoVersion = getDepNameWithNoVersion(depName);
const lines = fileContent.split(newlineRegex); const lines = fileContent.split(newlineRegex);
// istanbul ignore if: hard to test
if (lines.length <= upgrade.managerData.lineNumber) {
logger.warn('go.mod current line no longer exists after update');
return null;
}
const lineToChange = lines[upgrade.managerData.lineNumber]; const lineToChange = lines[upgrade.managerData.lineNumber];
if ( if (
!lineToChange.includes(depNameNoVersion) && !lineToChange.includes(depNameNoVersion) &&