Skip to content
This repository was archived by the owner on Oct 18, 2023. It is now read-only.

Commit c685048

Browse files
committed
Merge branch 'master' of github.com:nut-tree/opencv4nodejs
2 parents 9d92f44 + 5c91467 commit c685048

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

install/dependencies.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const { execSync } = require("child_process");
22
const isX64 = process.arch === "x64";
33

44
const install = (pkg) => {
5-
execSync(`npm install ${pkg}`);
5+
execSync(`npm install --no-save ${pkg}`);
66
}
77

88
const packages = {
@@ -21,9 +21,18 @@ if (!process.env["OPENCV4NODEJS_PREBUILT_SKIP_DEPENDENCIES"]) {
2121
}
2222

2323
const op = process.platform;
24+
let openCvVersion = process.env.npm_package_opencv;
2425

25-
console.log(`Installing prebuilt OpenCV v${process.env.npm_package_opencv} for plattform ${op}`);
26-
install(`@nut-tree/opencv-build-${op}@${process.env.npm_package_opencv}`);
26+
if (!openCvVersion) {
27+
// npm 7 no longer sets fields from the package.json in process.env so lookup the package.json
28+
// file we're running from. The environment variables are different when running locally vs
29+
// as a dependency
30+
const package = require(process.env.npm_package_from || process.env.npm_package_json);
31+
openCvVersion = package.opencv;
32+
}
33+
34+
console.log(`Installing prebuilt OpenCV v${openCvVersion} for platform ${op}`);
35+
install(`@nut-tree/opencv-build-${op}@${openCvVersion}`);
2736
packages[op].forEach(pkg => {
2837
console.log(`Installing additional runtime dependency '${pkg}'`);
2938
install(pkg);

0 commit comments

Comments
 (0)