nodejs-packaging/test/run
Jan Staněk e24e7dff07
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
2022-01-20 12:24:09 +01:00

19 lines
899 B
Bash
Executable File

#!/bin/sh
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 bundled_namespace
do
sed -e "s|//.*$||" < test/$test/package.json.in > test/$test/package.json
echo test/$test/package.json | ./nodejs.prov test/$test/package.json > test/$test/nodejs.prov.out 2> test/$test/nodejs.prov.err
diff -uw test/$test/nodejs.prov.err.exp test/$test/nodejs.prov.err || exit 1
diff -uw test/$test/nodejs.prov.out.exp test/$test/nodejs.prov.out || exit 1
echo test/$test/package.json | ./nodejs.req test/$test/package.json > test/$test/nodejs.req.out 2> test/$test/nodejs.req.err
diff -uw test/$test/nodejs.req.err.exp test/$test/nodejs.req.err || exit 1
diff -uw test/$test/nodejs.req.out.exp test/$test/nodejs.req.out || exit 1
done