Skip to content

Commit f8e2d1c

Browse files
Ian2020bbhtt
authored andcommitted
node: Correct LocalSource check in npm provider
Fix [#377](#377) and simplify the LocalSource check. Don't process the root package as a dependency. Assumes an entry without a resolved is always a local path.
1 parent 7090720 commit f8e2d1c

File tree

1 file changed

+5
-10
lines changed
  • node/flatpak_node_generator/providers

1 file changed

+5
-10
lines changed

node/flatpak_node_generator/providers/npm.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,20 +106,15 @@ def _process_packages_v2(
106106
# NOTE We're not interested in symlinks, NPM will create them at install time
107107
# but we still could collect package symlinks anyway just for completeness
108108
continue
109+
if install_path == '':
110+
# The root project is typically listed with a key of ''
111+
continue
109112

110113
name = info.get('name')
111114

112115
source: PackageSource
113-
package_json_path = lockfile.parent / install_path / 'package.json'
114-
if (
115-
'node_modules' not in install_path.split('/')
116-
and package_json_path.exists()
117-
):
118-
source = LocalSource(path=install_path)
119-
if name is None:
120-
with package_json_path.open('rb') as fp:
121-
name = json.load(fp)['name']
122-
elif 'resolved' in info:
116+
117+
if 'resolved' in info:
123118
resolved_url = urllib.parse.urlparse(info['resolved'])
124119
if resolved_url.scheme == 'file':
125120
source = LocalSource(path=resolved_url.path)

0 commit comments

Comments
 (0)