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

Commit 5eec362

Browse files
author
Simon Hofmann
committed
Added install script to install plattform specific OpenCV build, added it to preinstall scripts
1 parent 59ada18 commit 5eec362

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

install.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const { execSync } = require("child_process");
2+
const isX64 = process.arch === "x64";
3+
4+
const install = (pkg) => {
5+
execSync(`npm install ${pkg}`);
6+
}
7+
8+
const packages = {
9+
"darwin": [
10+
],
11+
"win32": [
12+
],
13+
"linux": [
14+
]
15+
}
16+
17+
if (!isX64) {
18+
console.log("Unsupported platform, only x64 is supported.");
19+
process.exit(-1);
20+
}
21+
22+
const op = process.platform;
23+
24+
console.log(`Installing prebuilt OpenCV v${process.env.npm_package_opencv} for plattform ${op}`);
25+
install(`@nut-tree/opencv-build-${op}@${process.env.npm_package_opencv}`);
26+
packages[op].forEach(pkg => {
27+
console.log(`Installing additional runtime dependency '${pkg}'`);
28+
install(pkg);
29+
});
30+
console.log(`Done.`);

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"main": "./lib/opencv4nodejs.js",
3434
"typings": "./lib/index.d.ts",
3535
"scripts": {
36+
"preinstall": "node ./install.js",
3637
"install": "prebuild-install --tag-prefix \"\" || node-gyp rebuild",
3738
"configure": "node-gyp configure",
3839
"build": "node-gyp configure build",
@@ -46,13 +47,13 @@
4647
"macro-inferno": "^0.2.3",
4748
"nan": "^2.12.1",
4849
"native-node-utils": "^0.1.5",
49-
"prebuild-install": "^5.3.0",
50-
"@nut-tree/opencv-build": "^1.0.0"
50+
"prebuild-install": "^5.3.0"
5151
},
5252
"optionalDependencies": {
5353
"@types/node": ">6"
5454
},
5555
"devDependencies": {
5656
"prebuild": "^8.2.0"
57-
}
57+
},
58+
"opencv": "3.4.6-beta3"
5859
}

0 commit comments

Comments
 (0)