Skip to content

Commit

Permalink
show path to package.json when erroring
Browse files Browse the repository at this point in the history
  • Loading branch information
jchavarri committed Aug 9, 2023
1 parent c149266 commit cfe4d54
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,12 @@ let check_npm_deps cli =
Printf.eprintf
"Error: opam package \"%s\" requires npm \
package \"%s\" with constraint \"%s\", but \
the version installed is \"%s\"\n"
the version installed found in file \"%s\" is \
\"%s\"\n"
(OpamPackage.to_string opam_pkg)
(OpamSysPkg.to_string npm_pkg)
npm_constraint installed_version))
npm_constraint (Path.showNormalized path)
installed_version))
npm_pkgs)
npm_pkgs_and_constraints)
l
Expand Down
6 changes: 3 additions & 3 deletions test/main.t
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ Errors when version does not match
$ yarn install --silent

$ opam-check-npm-deps
Error: opam package "test.dev" requires npm package "react-dom" with constraint "^16.0.2", but the version installed is "18.2.0"
Error: opam package "test.dev" requires npm package "react" with constraint "^16.0.2", but the version installed is "18.2.0"
Error: opam package "test.dev" requires npm package "react-dom" with constraint "^16.0.2", but the version installed found in file "$TESTCASE_ROOT/node_modules/react-dom/package.json" is "18.2.0"
Error: opam package "test.dev" requires npm package "react" with constraint "^16.0.2", but the version installed found in file "$TESTCASE_ROOT/node_modules/react/package.json" is "18.2.0"
[1]

$ opam pin remove -y test | grep "removed"
Expand Down Expand Up @@ -213,7 +213,7 @@ When --dry-run is used, exit code is 0
$ yarn install --silent

$ opam-check-npm-deps --dry-run
Error: opam package "test.dev" requires npm package "react" with constraint "^16.0.2", but the version installed is "18.2.0"
Error: opam package "test.dev" requires npm package "react" with constraint "^16.0.2", but the version installed found in file "$TESTCASE_ROOT/node_modules/react/package.json" is "18.2.0"

$ opam pin remove -y test | grep "removed"
-> removed test.dev

0 comments on commit cfe4d54

Please sign in to comment.