@iobroker/db-base 1.2.4 → 4.0.0-alpha.12-20211121-4ca7ec41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/tools.js +3 -47
- package/package.json +11 -6
package/lib/tools.js
CHANGED
|
@@ -1,51 +1,7 @@
|
|
|
1
|
-
const
|
|
2
|
-
const fs = require('fs');
|
|
1
|
+
const { tools } = require('@iobroker/js-controller-common');
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
for (const pkg of possibilities) {
|
|
7
|
-
try {
|
|
8
|
-
// package.json is guaranteed to be in the module root folder
|
|
9
|
-
// so once that is resolved, take the dirname and we're done
|
|
10
|
-
const possiblePath = require.resolve(`${pkg}/package.json`);
|
|
11
|
-
if (fs.existsSync(possiblePath)) {
|
|
12
|
-
return path.dirname(possiblePath);
|
|
13
|
-
}
|
|
14
|
-
} catch {
|
|
15
|
-
/* not found */
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Apparently, checking vs null/undefined may miss the odd case of controllerPath being ""
|
|
20
|
-
// Thus we check for falsyness, which includes failing on an empty path
|
|
21
|
-
let checkPath = path.join(__dirname, '../..');
|
|
22
|
-
// Also check in the current check dir (along with iobroker.js-controller subdirs)
|
|
23
|
-
possibilities.unshift('');
|
|
24
|
-
while (true) {
|
|
25
|
-
for (const pkg of possibilities) {
|
|
26
|
-
try {
|
|
27
|
-
const possiblePath = path.join(checkPath, pkg);
|
|
28
|
-
if (fs.existsSync(path.join(possiblePath, 'lib/tools.js'))) {
|
|
29
|
-
return possiblePath;
|
|
30
|
-
}
|
|
31
|
-
} catch {
|
|
32
|
-
// not found, continue with next possiblity
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// Controller not found here - go to the parent dir
|
|
37
|
-
const newPath = path.dirname(checkPath);
|
|
38
|
-
if (newPath === checkPath) {
|
|
39
|
-
// We already reached the root dir, abort
|
|
40
|
-
break;
|
|
41
|
-
}
|
|
42
|
-
checkPath = newPath;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const controllerDir = getControllerDir() || __dirname;
|
|
47
|
-
|
|
48
|
-
module.exports = require(path.join(controllerDir , 'lib/tools.js'));
|
|
3
|
+
module.exports = tools;
|
|
4
|
+
const controllerDir = tools.getControllerDir() || __dirname;
|
|
49
5
|
module.exports.getControllerDir = () => controllerDir;
|
|
50
6
|
|
|
51
7
|
/**
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iobroker/db-base",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.12-20211121-4ca7ec41",
|
|
4
4
|
"engines": {
|
|
5
|
-
"node": ">=
|
|
5
|
+
"node": ">=12.0.0"
|
|
6
6
|
},
|
|
7
7
|
"dependencies": {
|
|
8
|
+
"@iobroker/js-controller-common": "4.0.0-alpha.12-20211121-4ca7ec41",
|
|
8
9
|
"deep-clone": "^3.0.3",
|
|
9
|
-
"fs-extra": "^
|
|
10
|
+
"fs-extra": "^10.0.0",
|
|
10
11
|
"node.extend": "^2.0.2",
|
|
11
12
|
"respjs": "^4.2.0"
|
|
12
13
|
},
|
|
@@ -19,11 +20,11 @@
|
|
|
19
20
|
"contributors": [
|
|
20
21
|
"bluefox <dogafox@gmail.com>",
|
|
21
22
|
"Apollon77 <iobroker@fischer-ka.de>",
|
|
22
|
-
"foxriver76"
|
|
23
|
+
"foxriver76 <moritz.heusinger@gmail.com>"
|
|
23
24
|
],
|
|
24
25
|
"repository": {
|
|
25
26
|
"type": "git",
|
|
26
|
-
"url": "https://github.com/ioBroker/ioBroker.
|
|
27
|
+
"url": "https://github.com/ioBroker/ioBroker.js-controller/packages/db-base"
|
|
27
28
|
},
|
|
28
29
|
"scripts": {},
|
|
29
30
|
"main": "index.js",
|
|
@@ -31,5 +32,9 @@
|
|
|
31
32
|
"publishConfig": {
|
|
32
33
|
"access": "public"
|
|
33
34
|
},
|
|
34
|
-
"
|
|
35
|
+
"files": [
|
|
36
|
+
"lib/",
|
|
37
|
+
"index.js"
|
|
38
|
+
],
|
|
39
|
+
"gitHead": "fc84c4a314fefc8bb65182eb18b9573f79599237"
|
|
35
40
|
}
|