Skip to contentSkip to conversation

npmsw.py: Handle local tarball before registry

PATCH New John Ripple 1 participant 1 message Jun 23

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 npmsw.py: Handle local tarball before registry

The local tarball source must be checked before the registry sources because a local package can have a semver version and integrity field which would otherwise incorrectly match the registry sources branch producing a file:// proxy URL whose local.py fetcher leaves lockfile=None and eventually throws an error.

This patch was based on the npm and npmsw fetchers with the improved
security from Thomas Perrot's patches https://lists.openembedded.org/g/bitbake-devel/message/19705.

---
 lib/bb/fetch2/npmsw.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
lib/bb/fetch2/npmsw.py +4 -4
index f09ea5794..122af4582 100644
@@ -93,6 +93,10 @@ class NpmShrinkWrap(FetchMethod):
             if link:
                 localpath = resolved
                 unpack = False
+            
+            # Handle local tarball sources
+            elif resolved and resolved.startswith("file"):
+                localpath = resolved[5:]
 
             # Handle registry sources
             elif version and is_semver(version) and integrity:
@@ -139,10 +143,6 @@ class NpmShrinkWrap(FetchMethod):
 
                 localpath = os.path.join(d.getVar("DL_DIR"), localfile)
 
-            # Handle local tarball sources
-            elif resolved.startswith("file"):
-                localpath = resolved[5:]
-
             # Handle git sources
             elif resolved.startswith("git"):
                 regex = re.compile(r"""