nodejs.prov: find namespaced bundled dependencies
The previous behaviour assumed that in a bundled package path, there is always `node_modules` directory on each other spot – i.e.: npm/node_modules/<dep1>/node_modules/<subdep> ^ ^ With namespaced bundled packages, this is no longer necessary the truth: npm/node_modules/@nmcli/<dep1>/node_modules/… ^ ! – expected node_modules --- The previous implementation considered any directory not named `node_modules` as a package directory, and tried to process it as such. Among other things, it pruned the list of subdirectories to be processed to just another `node_modules` subdir, if that existed. With namespaced packages, this pruning in essence happened too soon, and so they were skipped altogether. With this patch applied, only directories that directly contain the `package.json` file are processed as package directories, meaning that the walk should correctly descend into namespaces (even nested ones, if they appear). Resolves: rhbz#2029904
This commit is contained in:
parent
b1c10eec41
commit
e24e7dff07
@ -93,9 +93,9 @@ def generate_dependencies(module_path, module_dir_set=NODE_MODULES):
|
||||
else: # Invalid metadata path
|
||||
raise ValueError("Invalid module path '%s'" % module_path)
|
||||
|
||||
for dir_path, subdir_list, __ in os.walk(root_dir):
|
||||
# Currently in node_modules (or similar), continue to subdirs
|
||||
if os.path.basename(dir_path) in module_dir_set:
|
||||
for dir_path, subdir_list, file_list in os.walk(root_dir):
|
||||
# We are only interested in directories that contain package.json
|
||||
if "package.json" not in file_list:
|
||||
continue
|
||||
|
||||
# Read and format metadata
|
||||
|
4
test/bundled_namespace/node_modules/@nmcli/test201/package.json
generated
vendored
Normal file
4
test/bundled_namespace/node_modules/@nmcli/test201/package.json
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "@nmcli/test201",
|
||||
"version": "2.1.4"
|
||||
}
|
4
test/bundled_namespace/node_modules/test200/package.json
generated
vendored
Normal file
4
test/bundled_namespace/node_modules/test200/package.json
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"name": "test200",
|
||||
"version": "1.3.5"
|
||||
}
|
0
test/bundled_namespace/nodejs.prov.err.exp
Normal file
0
test/bundled_namespace/nodejs.prov.err.exp
Normal file
3
test/bundled_namespace/nodejs.prov.out.exp
Normal file
3
test/bundled_namespace/nodejs.prov.out.exp
Normal file
@ -0,0 +1,3 @@
|
||||
bundled(nodejs-@nmcli/test201) = 2.1.4
|
||||
bundled(nodejs-test200) = 1.3.5
|
||||
npm(test) = 4.5.6
|
0
test/bundled_namespace/nodejs.req.err.exp
Normal file
0
test/bundled_namespace/nodejs.req.err.exp
Normal file
1
test/bundled_namespace/nodejs.req.out.exp
Normal file
1
test/bundled_namespace/nodejs.req.out.exp
Normal file
@ -0,0 +1 @@
|
||||
|
11
test/bundled_namespace/package.json.in
Normal file
11
test/bundled_namespace/package.json.in
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "test",
|
||||
"version": "4.5.6",
|
||||
"engines": {
|
||||
"node": ">=6 <10"
|
||||
},
|
||||
"dependencies": {
|
||||
"test100": "^1.2.3",
|
||||
"test101": ">=2.1"
|
||||
}
|
||||
}
|
2
test/run
2
test/run
@ -4,7 +4,7 @@ ln -sf nodejs.req nodejs_req.py
|
||||
"$(command -v python2 || echo :)" -m doctest nodejs_req.py || exit 1
|
||||
"$(command -v python3 || echo :)" -m doctest nodejs_req.py || exit 1
|
||||
|
||||
for test in unbundled bundled
|
||||
for test in unbundled bundled bundled_namespace
|
||||
do
|
||||
sed -e "s|//.*$||" < test/$test/package.json.in > test/$test/package.json
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user