feat: nodejs: package-lock: handle bundled dependenceis better

- assume bundled dep if type looks like http but resolved field is missing
- use path source type to handle bundled deps
This commit is contained in:
DavHau 2022-07-30 17:52:49 +02:00
parent b899116277
commit ee4a3e7062

View File

@ -216,7 +216,12 @@
getSourceType = dependencyObject:
if identifyGitSource dependencyObject
then "git"
else if lib.hasPrefix "file:" dependencyObject.version
else if
(lib.hasPrefix "file:" dependencyObject.version)
|| (
(! lib.hasPrefix "https://" dependencyObject.version)
&& (! dependencyObject ? resolved)
)
then "path"
else "http";
@ -245,11 +250,25 @@
};
path = dependencyObject:
dlib.construct.pathSource {
path = getPath dependencyObject;
rootName = project.name;
rootVersion = packageVersion;
};
# in case of an entry with missing resolved field
if
(! lib.hasPrefix "https://" dependencyObject.version)
&& (! dependencyObject ? resolved)
then
dlib.construct.pathSource {
path = let
module = l.elemAt (l.splitString "/" dependencyObject.pname) 0;
in "node_modules/${module}";
rootName = project.name;
rootVersion = packageVersion;
}
# in case of a "file:" entry
else
dlib.construct.pathSource {
path = getPath dependencyObject;
rootName = project.name;
rootVersion = packageVersion;
};
};
getDependencies = dependencyObject: