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

fix: resolve opencv version when running under npm 7 #10

Merged
merged 1 commit into from
Apr 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions install/dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { execSync } = require("child_process");
const isX64 = process.arch === "x64";

const install = (pkg) => {
execSync(`npm install ${pkg}`);
execSync(`npm install --no-save ${pkg}`);
}

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

const op = process.platform;
let openCvVersion = process.env.npm_package_opencv;

console.log(`Installing prebuilt OpenCV v${process.env.npm_package_opencv} for plattform ${op}`);
install(`@nut-tree/opencv-build-${op}@${process.env.npm_package_opencv}`);
if (!openCvVersion) {
// npm 7 no longer sets fields from the package.json in process.env so lookup the package.json
// file we're running from. The environment variables are different when running locally vs
// as a dependency
const package = require(process.env.npm_package_from || process.env.npm_package_json);
openCvVersion = package.opencv;
}

console.log(`Installing prebuilt OpenCV v${openCvVersion} for platform ${op}`);
install(`@nut-tree/opencv-build-${op}@${openCvVersion}`);
packages[op].forEach(pkg => {
console.log(`Installing additional runtime dependency '${pkg}'`);
install(pkg);
Expand Down