@iobroker/adapter-core
Advanced tools
Comparing version 2.6.0 to 2.6.1
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k; |
@@ -15,11 +15,10 @@ "use strict"; | ||
const possibilities = ["iobroker.js-controller", "ioBroker.js-controller"]; | ||
let controllerPath; | ||
// First try to let Node.js resolve the package by itself | ||
for (const pkg of possibilities) { | ||
try { | ||
const possiblePath = require.resolve(pkg); | ||
// package.json is guaranteed to be in the module root folder | ||
// so once that is resolved, take the dirname and we're done | ||
const possiblePath = require.resolve(`${pkg}/package.json`); | ||
if (fs.existsSync(possiblePath)) { | ||
// require.resolve returns the main file, we want the directory | ||
controllerPath = path.dirname(possiblePath); | ||
break; | ||
return path.dirname(possiblePath); | ||
} | ||
@@ -34,38 +33,34 @@ } | ||
// Thus we check for falsyness, which includes failing on an empty path | ||
if (!controllerPath) { | ||
let curDir = path.join(__dirname, "../node_modules"); | ||
let parentDir; | ||
outer: while (true) { | ||
for (const pkg of possibilities) { | ||
const possiblePath = path.join(curDir, pkg); | ||
try { | ||
if (fs.existsSync(possiblePath)) { | ||
controllerPath = possiblePath; | ||
break outer; | ||
} | ||
// We start in the node_modules subfolder of adapter-core, which is the deepest we should be able to expect the controller | ||
let curDir = path.join(__dirname, "../node_modules"); | ||
while (true) { | ||
for (const pkg of possibilities) { | ||
const possiblePath = path.join(curDir, pkg, "package.json"); | ||
try { | ||
// If package.json exists in the directory and its name field matches, we've found js-controller | ||
if (fs.existsSync(possiblePath) && | ||
JSON.parse(fs.readFileSync(possiblePath, "utf8")).name === | ||
pkg.toLowerCase()) { | ||
return path.dirname(possiblePath); | ||
} | ||
catch (_b) { | ||
// don't care | ||
} | ||
} | ||
// Nothing found here, go up one level | ||
parentDir = path.dirname(curDir); | ||
if (parentDir === curDir) { | ||
// we've reached the root without finding js-controller | ||
break; | ||
catch (_b) { | ||
// don't care | ||
} | ||
curDir = parentDir; | ||
} | ||
} | ||
if (!controllerPath) { | ||
if (!isInstall) { | ||
console.log("Cannot find js-controller"); | ||
return process.exit(10); | ||
// Nothing found here, go up one level | ||
const parentDir = path.dirname(curDir); | ||
if (parentDir === curDir) { | ||
// we've reached the root without finding js-controller | ||
break; | ||
} | ||
else { | ||
return process.exit(); | ||
} | ||
curDir = parentDir; | ||
} | ||
// we found the controller | ||
return controllerPath; | ||
if (!isInstall) { | ||
console.log("Cannot find js-controller"); | ||
return process.exit(10); | ||
} | ||
else { | ||
return process.exit(); | ||
} | ||
} | ||
@@ -72,0 +67,0 @@ /** The root directory of JS-Controller */ |
{ | ||
"name": "@iobroker/adapter-core", | ||
"version": "2.6.0", | ||
"version": "2.6.1", | ||
"description": "Core module to be used in ioBroker adapters. Acts as the bridge to js-controller.", | ||
@@ -38,31 +38,31 @@ "author": { | ||
"devDependencies": { | ||
"@alcalzone/release-script": "~3.5.2", | ||
"@alcalzone/release-script-plugin-license": "~3.5.0", | ||
"@types/chai": "^4.3.0", | ||
"@types/chai-as-promised": "^7.1.0", | ||
"@alcalzone/release-script": "~3.5.9", | ||
"@alcalzone/release-script-plugin-license": "~3.5.9", | ||
"@types/chai": "^4.3.3", | ||
"@types/chai-as-promised": "^7.1.5", | ||
"@types/mocha": "^9.1.0", | ||
"@types/node": "^16.11.21", | ||
"@types/node": "^18.7.14", | ||
"@types/proxyquire": "^1.3.28", | ||
"@types/sinon": "^10.0.6", | ||
"@types/sinon": "^10.0.11", | ||
"@types/sinon-chai": "^3.2.8", | ||
"@typescript-eslint/eslint-plugin": "^5.10.2", | ||
"@typescript-eslint/parser": "^5.10.2", | ||
"chai": "^4.2.0", | ||
"@typescript-eslint/eslint-plugin": "^5.36.1", | ||
"@typescript-eslint/parser": "^5.31.0", | ||
"chai": "^4.3.6", | ||
"chai-as-promised": "^7.1.1", | ||
"eslint": "^8.8.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"mocha": "^9.2.0", | ||
"prettier": "^2.5.1", | ||
"eslint": "^8.23.0", | ||
"eslint-config-prettier": "^8.5.0", | ||
"eslint-plugin-prettier": "^4.2.1", | ||
"mocha": "^9.2.2", | ||
"prettier": "^2.7.1", | ||
"proxyquire": "^2.1.0", | ||
"rimraf": "^3.0.0", | ||
"sinon": "^13.0.0", | ||
"sinon": "^13.0.2", | ||
"sinon-chai": "^3.7.0", | ||
"source-map-support": "^0.5.21", | ||
"ts-node": "^10.4.0", | ||
"typescript": "^4.5.5" | ||
"ts-node": "^10.9.1", | ||
"typescript": "^4.8.2" | ||
}, | ||
"dependencies": { | ||
"@types/iobroker": "^4.0.1" | ||
"@types/iobroker": "^4.0.4" | ||
} | ||
} |
@@ -93,2 +93,6 @@ # Adapter-Core | ||
--> | ||
### 2.6.1 (2022-09-06) | ||
- (AlCalzone) Fix: detecting JS-Controller now finds the correct directory and not a subdirectory. | ||
### 2.6.0 (2022-02-20) | ||
@@ -95,0 +99,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
24828
162
305
1
Updated@types/iobroker@^4.0.4