Skip to content

Commit

Permalink
fix strict type error
Browse files Browse the repository at this point in the history
  • Loading branch information
UrielCh committed Apr 30, 2024
1 parent 2c31eb0 commit 55bf9d8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
26 changes: 14 additions & 12 deletions src/install/compileLib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,10 @@ export async function compileLib(args: string[]) {
action = 'rebuild';
}
}
const extra = buildOptions.extra || {};

if (buildOptions.extra.jobs) {
JOBS = buildOptions.extra.jobs;
if (extra.jobs) {
JOBS = extra.jobs;
}

if (buildOptions.disableAutoBuild || toBool(env.OPENCV4NODEJS_DISABLE_AUTOBUILD) || npmEnv.disableAutoBuild) {
Expand All @@ -245,14 +246,15 @@ export async function compileLib(args: string[]) {
}
}

if (buildOptions.extra['dry-run'] || buildOptions.extra['dryrun']) {
if (extra['dry-run'] || extra['dryrun']) {
dryRun = true;
}

if (!silenceMode) {
for (const K in ['autoBuildFlags']) {
const K = 'autoBuildFlags' as const;
// for (const K in ['autoBuildFlags'] as const) {
if (buildOptions[K]) console.log(`using ${K}:`, buildOptions[K]);
}
// }
}

try {
Expand Down Expand Up @@ -309,7 +311,7 @@ or use OPENCV4NODEJS_* env variable.`)


if (silenceMode) {
const outputs = process.env[actionOriginal].split(/[\n;]/);
const outputs = (process.env[actionOriginal] || '').split(/[\n;]/);
outputs.forEach(o => console.log(o));
return;
}
Expand All @@ -325,7 +327,7 @@ or use OPENCV4NODEJS_* env variable.`)
// --verbose, --loglevel=verbose Log most progress to console
// --silent, --loglevel=silent Don't log anything to console

if (process.env.BINDINGS_DEBUG || buildOptions.extra['debug'])
if (process.env.BINDINGS_DEBUG || extra['debug'])
flags += ' --debug';
else
flags += ' --release';
Expand All @@ -336,12 +338,12 @@ or use OPENCV4NODEJS_* env variable.`)

// const arch = 'x86_64' / 'x64'
// flags += --arch=${arch} --target_arch=${arch}
const cmdOptions = buildOptions.extra['node-gyp-options'] || '';
const cmdOptions = extra['node-gyp-options'] || '';
flags += ` ${cmdOptions}`;

const nodegyp = buildOptions.extra.electron ? 'electron-rebuild' : 'node-gyp';
const nodegyp = extra.electron ? 'electron-rebuild' : 'node-gyp';
let nodegypCmd = '';
for (const dir of process.env.PATH.split(path.delimiter)) {
for (const dir of (process.env.PATH || '').split(path.delimiter)) {
nodegypCmd = getExistingBin(dir, nodegyp);
if (nodegypCmd) {
// no need to use full path
Expand Down Expand Up @@ -376,7 +378,7 @@ or use OPENCV4NODEJS_* env variable.`)

log('info', 'install', `Spawning in directory:${cwd} node-gyp process: ${nodegypCmd}`)

if (buildOptions.extra.vscode) {
if (extra.vscode) {
// const nan = require('nan');
// const nativeNodeUtils = require('native-node-utils');
// const pblob = promisify(blob)
Expand Down Expand Up @@ -433,7 +435,7 @@ or use OPENCV4NODEJS_* env variable.`)
// }
const child = child_process.exec(nodegypCmd, { maxBuffer: Infinity, cwd }, function callNodegypCmd(error/*, stdout, stderr*/) {
// fs.unlinkSync(realGyp);
const bin = buildOptions.extra.electron ? 'electron-rebuild' : 'node-gyp';
const bin = extra.electron ? 'electron-rebuild' : 'node-gyp';
if (error) {
console.log(`error: `, error);
log('error', 'install', `${bin} failed and return ${error.name} ${error.message} return code: ${error.code}`);
Expand Down
5 changes: 2 additions & 3 deletions src/lib/ext/deprecations.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import assert from 'assert';
import type * as openCV from '../../../typings/index.js'
import type { Mat } from '../../../typings/index.js';

let cv: typeof openCV;
let _calcHist: (img: Mat, histAxes: openCV.HistAxes[], mask?: Mat) => Mat;
let _calcHist: (img: openCV.Mat, histAxes: openCV.HistAxes[], mask?: openCV.Mat) => openCV.Mat;

function calcHist(img: Mat, histAxes: { channel: number, bins: number, ranges: [number, number] }[], mask?: Mat) {
function calcHist(img: openCV.Mat, histAxes: { channel: number, bins: number, ranges: [number, number] }[], mask?: openCV.Mat) {
assert(img instanceof cv.Mat, 'Imgproc::CalcHist - Error: expected argument 0 to be of type Mat');
assert(Array.isArray(histAxes), 'Imgproc::CalcHist - Error: expected argument 1 to be of type array of HistAxes');

Expand Down

0 comments on commit 55bf9d8

Please sign in to comment.