Patch is unrecognized if it is for a version prefixed with a 'v'
- Dominant language
- TypeScript
- Stars
- 11.2k
- Forks
- 325
- PR merge metrics
- No merged PRs in 30d
Description
This package happily creates a diff patch for a package that has a version starting with a 'v' but then fails to apply that patch, throwing the following warning:
```
Unrecognized patch file in patches directory serverless-plugin-aws-alerts+v1.7.3.patch
```
If I edit PackageDetails.js to drop the 'v' from the version, it somehow just works:
```
function parseNameAndVersion(s) {
const parts = s.split("+");
parts[1] = '1.7.3'
switch (parts.length) {
```
The logic in `parseNameAndVersion` seems odd to me as you are returning the package name as name/version if the version doesn't match a regex of digits:
```
return { name: `${nameOrScope}/${versionOrName}` };
```
Yet, in `getPackageDetailsFromPatchFilename` you explicitly expect that you will have a version key in a map after returning from `parseNameAndVersion`:
```
const lastPart = parts[parts.length - 1];
if (!lastPart.version) {
return null;
}
```
Seems you assume that if `versionOrName` isn't a digit then the parts must correspond to scope/name, which is false in this case.
In my case, the obvious work-around that somehow works is to drop the 'v' from the patch name, but this isn't obvious to anyone who expects the plugin to just work out of the box. :)
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.