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

Commit 9fc9acf

Browse files
author
Simon Hofmann
committed
Updated PATH settings for Windows
1 parent acdeb7a commit 9fc9acf

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

lib/cv.js

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,42 @@
1-
const path = require('path');
2-
const { resolvePath } = require('./commons');
1+
const path = require("path");
2+
const { resolvePath } = require("./commons");
3+
4+
let winLibsPath;
5+
if (process.env.BINDINGS_DEBUG) {
6+
winLibsPath = "../build/Debug/opencv4nodejs";
7+
} else {
8+
winLibsPath = "../build/Release/opencv4nodejs";
9+
}
10+
// ensure binaries are added to path on windows
11+
if (process.platform === "win32") {
12+
// append opencv binary path to node process
13+
if (!process.env.path.includes(winLibsPath)) {
14+
process.env.path = `${process.env.path};${winLibsPath};`;
15+
}
16+
}
317

418
let cv;
519
if (process.env.BINDINGS_DEBUG) {
6-
cv = require(path.join(__dirname, '../build/Debug/opencv4nodejs'));
20+
cv = require(path.join(__dirname, "../build/Debug/opencv4nodejs"));
721
} else {
8-
cv = require(path.join(__dirname, '../build/Release/opencv4nodejs'));
22+
cv = require(path.join(__dirname, "../build/Release/opencv4nodejs"));
923
}
1024

1125
// resolve haarcascade files
1226
const { haarCascades, lbpCascades } = cv;
1327
Object.keys(haarCascades).forEach(
14-
key => cv[key] = resolvePath(path.join(__dirname, './haarcascades'), haarCascades[key]));
28+
key =>
29+
(cv[key] = resolvePath(
30+
path.join(__dirname, "./haarcascades"),
31+
haarCascades[key]
32+
))
33+
);
1534
Object.keys(lbpCascades).forEach(
16-
key => cv[key] = resolvePath(path.join(__dirname, './lbpcascades'), lbpCascades[key]));
35+
key =>
36+
(cv[key] = resolvePath(
37+
path.join(__dirname, "./lbpcascades"),
38+
lbpCascades[key]
39+
))
40+
);
1741

1842
module.exports = cv;

0 commit comments

Comments
 (0)