Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

opencv-build

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

opencv-build - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

3

build/env.d.ts

@@ -6,5 +6,6 @@ import { AutoBuildFile } from './types';

export declare function autoBuildFlags(): string;
export declare function parseAutoBuildFlags(): string[];
export declare function opencvVersion(): string;
export declare function numberOfCoresAvailable(): number;
export declare function parseAutoBuildFlags(): string[];
export declare function readAutoBuildFile(): AutoBuildFile | undefined;
export declare function readEnvsFromPackageJson(): void;

@@ -5,2 +5,3 @@ "use strict";

var os = require("os");
var path = require("path");
var dirs_1 = require("./dirs");

@@ -24,2 +25,10 @@ var log = require('npmlog');

exports.autoBuildFlags = autoBuildFlags;
function opencvVersion() {
return process.env.OPENCV4NODEJS_AUTOBUILD_OPENCV_VERSION || '3.4.6';
}
exports.opencvVersion = opencvVersion;
function numberOfCoresAvailable() {
return os.cpus().length;
}
exports.numberOfCoresAvailable = numberOfCoresAvailable;
function parseAutoBuildFlags() {

@@ -34,10 +43,2 @@ var flagStr = autoBuildFlags();

exports.parseAutoBuildFlags = parseAutoBuildFlags;
function opencvVersion() {
return process.env.OPENCV4NODEJS_AUTOBUILD_OPENCV_VERSION || '3.4.6';
}
exports.opencvVersion = opencvVersion;
function numberOfCoresAvailable() {
return os.cpus().length;
}
exports.numberOfCoresAvailable = numberOfCoresAvailable;
function readAutoBuildFile() {

@@ -61,1 +62,56 @@ try {

exports.readAutoBuildFile = readAutoBuildFile;
function parsePackageJson() {
if (!process.env.INIT_CWD) {
log.error('process.env.INIT_CWD is undefined or empty');
return;
}
var absPath = path.resolve(process.env.INIT_CWD, 'package.json');
if (!fs.existsSync(absPath)) {
log.info('No package.json in folder.');
return;
}
try {
return JSON.parse(fs.readFileSync(absPath).toString());
}
catch (error) {
log.error('failed to parse package.json:');
log.error(error);
}
}
function readEnvsFromPackageJson() {
var rootPackageJSON = parsePackageJson();
if (!rootPackageJSON || !rootPackageJSON.opencv4nodejs) {
return;
}
var envs = Object.keys(rootPackageJSON.opencv4nodejs);
if (envs.length) {
log.info('the following opencv4nodejs environment variables are set in the package.json:');
envs.forEach(function (key) { return log.info(key + ": " + rootPackageJSON.opencv4nodejs[key]); });
}
var _a = rootPackageJSON.opencv4nodejs, autoBuildBuildCuda = _a.autoBuildBuildCuda, autoBuildFlags = _a.autoBuildFlags, autoBuildOpenCVVersion = _a.autoBuildOpenCVVersion, autoBuildWithoutContrib = _a.autoBuildWithoutContrib, disableAutoBuild = _a.disableAutoBuild, opencvIncludeDir = _a.opencvIncludeDir, opencvLibDir = _a.opencvLibDir, opencvBinDir = _a.opencvBinDir;
if (autoBuildFlags) {
process.env.OPENCV4NODEJS_AUTOBUILD_FLAGS = autoBuildFlags;
}
if (autoBuildBuildCuda) {
process.env.OPENCV4NODEJS_BUILD_CUDA = autoBuildBuildCuda;
}
if (autoBuildOpenCVVersion) {
process.env.OPENCV4NODEJS_AUTOBUILD_OPENCV_VERSION = autoBuildOpenCVVersion;
}
if (autoBuildWithoutContrib) {
process.env.OPENCV4NODEJS_AUTOBUILD_WITHOUT_CONTRIB = autoBuildWithoutContrib;
}
if (disableAutoBuild) {
process.env.OPENCV4NODEJS_DISABLE_AUTOBUILD = disableAutoBuild;
}
if (opencvIncludeDir) {
process.env.OPENCV_INCLUDE_DIR = opencvIncludeDir;
}
if (opencvLibDir) {
process.env.OPENCV_LIB_DIR = opencvIncludeDir;
}
if (opencvBinDir) {
process.env.OPENCV_BIN_DIR = opencvBinDir;
}
}
exports.readEnvsFromPackageJson = readEnvsFromPackageJson;
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -8,0 +9,0 @@ });

export { opencvModules } from './constants';
export { isAutoBuildDisabled, readAutoBuildFile } from './env';
export { isAutoBuildDisabled, readAutoBuildFile, readEnvsFromPackageJson } from './env';
export { isOSX, isWin, isUnix } from './utils';
export declare const opencvInclude: string;

@@ -4,0 +5,0 @@ export declare const opencv4Include: string;

@@ -14,2 +14,7 @@ "use strict";

exports.readAutoBuildFile = env_1.readAutoBuildFile;
exports.readEnvsFromPackageJson = env_1.readEnvsFromPackageJson;
var utils_2 = require("./utils");
exports.isOSX = utils_2.isOSX;
exports.isWin = utils_2.isWin;
exports.isUnix = utils_2.isUnix;
exports.opencvInclude = dirs_1.dirs.opencvInclude;

@@ -16,0 +21,0 @@ exports.opencv4Include = dirs_1.dirs.opencv4Include;

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -70,21 +71,9 @@ });

return __awaiter(this, void 0, void 0, function () {
var rootPackageJSON, autoBuildFile, hasLibs, err_1;
var autoBuildFile, hasLibs, err_1;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
if (process.env.INIT_CWD) {
rootPackageJSON = require(path.resolve(process.env.INIT_CWD, 'package.json'));
if (rootPackageJSON.opencv4nodejs &&
rootPackageJSON.opencv4nodejs.autoBuildFlags) {
if (process.env.OPENCV4NODEJS_AUTOBUILD_FLAGS) {
process.env.OPENCV4NODEJS_AUTOBUILD_FLAGS = [
process.env.OPENCV4NODEJS_AUTOBUILD_FLAGS,
rootPackageJSON.opencv4nodejs.autoBuildFlags
].join(' ');
}
else {
process.env.OPENCV4NODEJS_AUTOBUILD_FLAGS = rootPackageJSON.opencv4nodejs.autoBuildFlags;
}
}
}
// if project directory has a package.json containing opencv4nodejs variables
// apply these variables to the process environment
env_1.readEnvsFromPackageJson();
if (env_1.isAutoBuildDisabled()) {

@@ -91,0 +80,0 @@ log.info('install', 'OPENCV4NODEJS_DISABLE_AUTOBUILD is set');

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -8,0 +9,0 @@ });

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());

@@ -8,0 +9,0 @@ });

{
"name": "opencv-build",
"version": "0.1.5",
"version": "0.1.6",
"description": "A simple script to auto build recent OpenCV + contrib version via npm",

@@ -27,10 +27,10 @@ "main": "./build/index.js",

"dependencies": {
"@types/node": "^11.10.5",
"npmlog": "^4.1.2"
},
"devDependencies": {
"chai": "^4.1.2",
"mocha": "^5.0.5",
"typescript": "^3.3.3333"
"@types/node": "^12.7.4",
"chai": "^4.2.0",
"mocha": "^6.2.0",
"typescript": "^3.6.2"
}
}
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';

@@ -25,2 +26,10 @@ import { dirs } from './dirs';

export function opencvVersion() {
return process.env.OPENCV4NODEJS_AUTOBUILD_OPENCV_VERSION || '3.4.6'
}
export function numberOfCoresAvailable() {
return os.cpus().length
}
export function parseAutoBuildFlags(): string[] {

@@ -35,10 +44,2 @@ const flagStr = autoBuildFlags()

export function opencvVersion() {
return process.env.OPENCV4NODEJS_AUTOBUILD_OPENCV_VERSION || '3.4.6'
}
export function numberOfCoresAvailable() {
return os.cpus().length
}
export function readAutoBuildFile(): AutoBuildFile | undefined {

@@ -59,2 +60,77 @@ try {

return undefined
}
function parsePackageJson() {
if (!process.env.INIT_CWD) {
log.error('process.env.INIT_CWD is undefined or empty')
return
}
const absPath = path.resolve(process.env.INIT_CWD, 'package.json')
if (!fs.existsSync(absPath)) {
log.info('No package.json in folder.')
return
}
try {
return JSON.parse(fs.readFileSync(absPath).toString())
} catch (error) {
log.error('failed to parse package.json:')
log.error(error)
}
}
export function readEnvsFromPackageJson() {
const rootPackageJSON = parsePackageJson()
if (!rootPackageJSON || !rootPackageJSON.opencv4nodejs) {
return
}
const envs = Object.keys(rootPackageJSON.opencv4nodejs)
if (envs.length) {
log.info('the following opencv4nodejs environment variables are set in the package.json:')
envs.forEach(key => log.info(`${key}: ${rootPackageJSON.opencv4nodejs[key]}`))
}
const {
autoBuildBuildCuda,
autoBuildFlags,
autoBuildOpenCVVersion,
autoBuildWithoutContrib,
disableAutoBuild,
opencvIncludeDir,
opencvLibDir,
opencvBinDir
} = rootPackageJSON.opencv4nodejs
if (autoBuildFlags) {
process.env.OPENCV4NODEJS_AUTOBUILD_FLAGS = autoBuildFlags
}
if (autoBuildBuildCuda) {
process.env.OPENCV4NODEJS_BUILD_CUDA = autoBuildBuildCuda
}
if (autoBuildOpenCVVersion) {
process.env.OPENCV4NODEJS_AUTOBUILD_OPENCV_VERSION = autoBuildOpenCVVersion
}
if (autoBuildWithoutContrib) {
process.env.OPENCV4NODEJS_AUTOBUILD_WITHOUT_CONTRIB = autoBuildWithoutContrib
}
if (disableAutoBuild) {
process.env.OPENCV4NODEJS_DISABLE_AUTOBUILD = disableAutoBuild
}
if (opencvIncludeDir) {
process.env.OPENCV_INCLUDE_DIR = opencvIncludeDir
}
if (opencvLibDir) {
process.env.OPENCV_LIB_DIR = opencvIncludeDir
}
if (opencvBinDir) {
process.env.OPENCV_BIN_DIR = opencvBinDir
}
}

@@ -7,6 +7,7 @@ import * as fs from 'fs';

import { getLibsFactory } from './getLibsFactory';
import { isOSX, isWin } from './utils';
import { isOSX, isUnix, isWin } from './utils';
export { opencvModules } from './constants';
export { isAutoBuildDisabled, readAutoBuildFile } from './env';
export { isAutoBuildDisabled, readAutoBuildFile, readEnvsFromPackageJson } from './env';
export { isOSX, isWin, isUnix } from './utils';
export const opencvInclude = dirs.opencvInclude

@@ -13,0 +14,0 @@ export const opencv4Include = dirs.opencv4Include

@@ -6,3 +6,10 @@ import * as fs from 'fs';

import { dirs } from './dirs';
import { autoBuildFlags, isAutoBuildDisabled, readAutoBuildFile, opencvVersion, isWithoutContrib } from './env';
import {
autoBuildFlags,
isAutoBuildDisabled,
isWithoutContrib,
opencvVersion,
readAutoBuildFile,
readEnvsFromPackageJson,
} from './env';
import { getLibsFactory } from './getLibsFactory';

@@ -42,21 +49,6 @@ import { setupOpencv } from './setupOpencv';

export async function install() {
if (process.env.INIT_CWD) {
let rootPackageJSON = require(path.resolve(process.env.INIT_CWD, 'package.json'))
// if project directory has a package.json containing opencv4nodejs variables
// apply these variables to the process environment
readEnvsFromPackageJson()
if (rootPackageJSON.opencv4nodejs &&
rootPackageJSON.opencv4nodejs.autoBuildFlags) {
if (process.env.OPENCV4NODEJS_AUTOBUILD_FLAGS) {
process.env.OPENCV4NODEJS_AUTOBUILD_FLAGS = [
process.env.OPENCV4NODEJS_AUTOBUILD_FLAGS,
rootPackageJSON.opencv4nodejs.autoBuildFlags
].join(' ')
} else {
process.env.OPENCV4NODEJS_AUTOBUILD_FLAGS = rootPackageJSON.opencv4nodejs.autoBuildFlags
}
}
}
if (isAutoBuildDisabled()) {

@@ -63,0 +55,0 @@ log.info('install', 'OPENCV4NODEJS_DISABLE_AUTOBUILD is set')

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc