Skip to content

Commit

Permalink
v196
Browse files Browse the repository at this point in the history
  • Loading branch information
udarrr committed Jul 3, 2023
1 parent 6c58906 commit c41b26d
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 23 deletions.
47 changes: 27 additions & 20 deletions install/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const pack_1 = require("../build_release_opencv/pack");
const Downloader = require("nodejs-file-downloader");
const packageJson = require("../package.json");
const path = require("path");
const { existsSync } = require("fs");
const file = `opencv_${process.platform}_${packageJson.opencv4nodejs.autoBuildOpencvVersion}_${process.arch}.tgz`;
console.log(file);

Expand All @@ -12,33 +13,29 @@ async function download() {

try {
if (process.platform === "darwin" && process.arch !== "arm64") {
await new Downloader({
url: libUrl,
directory: path.join(process.cwd(), "osOpencvWorlds", "darwin"),
}).download();
const pathToLib = `${path.join(process.cwd(), "osOpencvWorlds", "darwin", file)}`;
const pathToDir = path.join(process.cwd(), "osOpencvWorlds", "darwin");

await pack_1.Pack.unpack(`${path.join(process.cwd(), "osOpencvWorlds", "darwin")}`, `${path.join(process.cwd(), "osOpencvWorlds", "darwin", file)}`);
await downloadIfExist(pathToDir, pathToLib, libUrl);
await pack_1.Pack.unpack(pathToDir, pathToLib);
} else if (process.platform === "darwin" && process.arch === "arm64") {
await new Downloader({
url: libUrl,
directory: path.join(process.cwd(), "osOpencvWorlds", "darwinM1"),
}).download();
const pathToLib = `${path.join(process.cwd(), "osOpencvWorlds", "darwinM1", file)}`;
const pathToDir = `${path.join(process.cwd(), "osOpencvWorlds", "darwinM1")}`;

await pack_1.Pack.unpack(`${path.join(process.cwd(), "osOpencvWorlds", "darwinM1")}`, `${path.join(process.cwd(), "osOpencvWorlds", "darwinM1", file)}`);
await downloadIfExist(pathToDir, pathToLib, libUrl);
await pack_1.Pack.unpack(pathToDir, pathToLib);
} else if (process.platform === "linux") {
await new Downloader({
url: libUrl,
directory: path.join(process.cwd(), "osOpencvWorlds", "linux"),
}).download();
const pathToLib = `${path.join(process.cwd(), "osOpencvWorlds", "linux", file)}`;
const pathToDir = `${path.join(process.cwd(), "osOpencvWorlds", "linux")}`;

await pack_1.Pack.unpack(`${path.join(process.cwd(), "osOpencvWorlds", "linux")}`, `${path.join(process.cwd(), "osOpencvWorlds", "linux", file)}`);
await downloadIfExist(pathToDir, pathToLib);
await pack_1.Pack.unpack(pathToDir, pathToLib, libUrl);
} else if (process.platform === "win32") {
await new Downloader({
url: libUrl,
directory: path.join(process.cwd(), "osOpencvWorlds", "win32"),
}).download();
const pathToLib = `${path.join(process.cwd(), "osOpencvWorlds", "win32", file)}`;
const pathToDir = `${path.join(process.cwd(), "osOpencvWorlds", "win32")}`;

await pack_1.Pack.unpack(`${path.join(process.cwd(), "osOpencvWorlds", "win32")}`, `${path.join(process.cwd(), "osOpencvWorlds", "win32", file)}`);
await downloadIfExist(pathToDir, pathToLib, libUrl);
await pack_1.Pack.unpack(pathToDir, pathToLib);
}
await new Promise((res) =>
setTimeout(() => {
Expand All @@ -50,4 +47,14 @@ async function download() {
console.log("Download failed", error);
}
}

async function downloadIfExist(pathToDir, pathToLib, libUrl) {
if (!existsSync(pathToLib)) {
await new Downloader({
url: libUrl,
directory: pathToDir,
}).download();
}
}

download();
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "opencv4nodejs-prebuilt-install",
"version": "4.1.195",
"version": "4.1.196",
"description": "Asynchronous OpenCV 4.x nodejs bindings with JavaScript and TypeScript API.",
"keywords": [
"opencv",
Expand Down

0 comments on commit c41b26d

Please sign in to comment.