Skip to content

Commit

Permalink
fix for linux
Browse files Browse the repository at this point in the history
  • Loading branch information
udarrr committed Aug 22, 2023
1 parent 33a839e commit f5d57e3
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 17 deletions.
70 changes: 56 additions & 14 deletions install/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,63 @@ const { existsSync } = require("fs");
const file = `opencv_${process.platform}_${packageJson.opencv4nodejs.autoBuildOpencvVersion}_${process.arch}.tgz`;
console.log(file);

async function download() {
async function downloadLib() {
let libUrl = `https://github.com/udarrr/opencv4nodejs-prebuilt-install/releases/download/v${packageJson.version}/${file}`;

try {
if (process.platform === "darwin" && process.arch !== "arm64") {
const pathToLib = `${path.join(process.cwd(), "osOpencvWorlds", "darwin", file)}`;
const pathToLib = `${path.join(
process.cwd(),
"osOpencvWorlds",
"darwin",
file
)}`;
const pathToDir = path.join(process.cwd(), "osOpencvWorlds", "darwin");

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

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

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

await downloadIfExist(pathToDir, pathToLib, libUrl);
await pack_1.Pack.unpack(pathToDir, pathToLib);
Expand All @@ -50,11 +82,21 @@ async function download() {

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

const downloaderInstance = new Downloader({
url: libUrl,
directory: pathToDir,
}).download();
directory: pathToDir
});
const report = await downloaderInstance.download();

console.log(JSON.stringify(report));
}
}

download();
downloadLib();
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.197",
"version": "4.1.201",
"description": "Asynchronous OpenCV 4.x nodejs bindings with JavaScript and TypeScript API.",
"keywords": [
"opencv",
Expand Down

0 comments on commit f5d57e3

Please sign in to comment.