Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanBluefox committed Sep 2, 2024
1 parent 2b721ea commit 8a06484
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 30 deletions.
4 changes: 2 additions & 2 deletions lib/debug.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const fork = require('child_process').fork;
const fork = require('node:child_process').fork;

const adapter = {
log: {
Expand Down Expand Up @@ -151,4 +151,4 @@ function debugScript(data) {
});
}

debugScript({ scriptName: 'script.js.Skript_1' });
debugScript({ scriptName: 'script.js.Skript_1' });
8 changes: 4 additions & 4 deletions lib/debugger.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
* IN THE SOFTWARE.
*/
'use strict';
//const FS = require('fs');
const Path = require('path');
// const FS = require('fs');
const Path = require('node:path');
const Repl = require('repl');
const util = require('util');
const util = require('node:util');
const vm = require('vm');
const fileURLToPath = require('url').fileURLToPath;
const fileURLToPath = require('node:url').fileURLToPath;

const debuglog = util.debuglog('inspect');

Expand Down
12 changes: 6 additions & 6 deletions lib/inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
* IN THE SOFTWARE.
*/
'use strict';
const { spawn } = require('child_process');
const { EventEmitter } = require('events');
const net = require('net');
const util = require('util');
const path = require('path');
const fs = require('fs');
const { spawn } = require('node:child_process');
const { EventEmitter } = require('node:events');
const net = require('node:net');
const util = require('node:util');
const path = require('node:path');
const fs = require('node:fs');

let breakOnStart;
for (let i = 0; i < process.argv.length; i++) {
Expand Down
38 changes: 20 additions & 18 deletions lib/mirror.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';
const fs = require('fs');
const path = require('path');
const fs = require('node:fs');
const path = require('node:path');

const MODE_0777 = 511;

Expand All @@ -25,12 +25,12 @@ class Mirror {
this.lastSyncID = `${this.from}.lastSync`;

this.log = options.log || {
silly: text => console.log(text),
debug: text => console.log(text),
info: text => console.log(text),
log: text => console.log(text),
warn: text => console.warn(text),
error: text => console.error(text)
silly: text => console.log(text),
debug: text => console.log(text),
info: text => console.log(text),
log: text => console.log(text),
warn: text => console.warn(text),
error: text => console.error(text),
};

if (!fs.existsSync(this.diskRoot)) {
Expand Down Expand Up @@ -99,7 +99,7 @@ class Mirror {
this.log.error(`Please check that no other processes change data in the mirror directory!`);
}

this.watchedFolder[root_].on('error', err => {
this.watchedFolder[root_].on('error', () => {
this.log.debug(`Folder ${root_} was deleted`);
try {
this.watchedFolder[root_] && this.watchedFolder[root_].close();
Expand All @@ -115,7 +115,7 @@ class Mirror {
}

checkLastSyncObject(cb) {
this.adapter.getForeignObject(this.lastSyncID, (err, obj) => {
this.adapter.getForeignObject(this.lastSyncID, (_err, obj) => {
if (!obj) {
// create variable
const obj = {
Expand All @@ -128,13 +128,13 @@ class Mirror {
min: 0,
read: true,
},
type: 'state'
type: 'state',
};

this.adapter.setForeignObject(this.lastSyncID, obj, () =>
this.adapter.setForeignState(this.lastSyncID, 0, true, () => cb && cb(0)));
} else {
this.adapter.getForeignState(this.lastSyncID, (err, state) =>
this.adapter.getForeignState(this.lastSyncID, (_err, state) =>
cb && cb(state && state.val));
}
});
Expand Down Expand Up @@ -219,7 +219,7 @@ class Mirror {
const diskListEntry = this.diskList[id];
try {
//check if the directory exists and create if not:
fs.mkdirSync(path.dirname(diskListEntry.name), {recursive: true, mode: MODE_0777});
fs.mkdirSync(path.dirname(diskListEntry.name), { recursive: true, mode: MODE_0777 });
fs.writeFileSync(diskListEntry.name, diskListEntry.source, {mode: MODE_0777});
diskListEntry.ts = Date.now();
return true;
Expand Down Expand Up @@ -588,8 +588,8 @@ class Mirror {
}

scanDB(cb) {
this.adapter.getObjectView('system', 'channel', {startkey: 'script.js.', endkey: 'script.js.\u9999'}, (err, res) => {
// this is not required, because javascript subscribes on ALL objects
this.adapter.getObjectView('system', 'channel', { startkey: 'script.js.', endkey: 'script.js.\u9999' }, (err, res) => {
// this is not required, because JavaScript subscribes on ALL objects
// adapter.subscribeForeignObjects('script.js.*');
const list = {};
if (err) {
Expand All @@ -603,7 +603,7 @@ class Mirror {
}
}
}
this.adapter.getObjectView('script', 'javascript', {startkey: 'script.js.', endkey: 'script.js.\u9999'}, (err, res) => {
this.adapter.getObjectView('script', 'javascript', { startkey: 'script.js.', endkey: 'script.js.\u9999' }, (err, res) => {
if (err) {
this.log.error(`Error while checking scripts javascript from objects database: ${err}`);
}
Expand All @@ -612,12 +612,14 @@ class Mirror {
const value = res.rows[i].value;
if (value && value._id && value.common) {
list[res.rows[i].value._id] = res.rows[i].value;
// ensure that every script has a folder and if not then create it
// ensure that every script has a folder and if not, then create it
this._checkIfAllFoldersAreExist(res.rows[i].value._id, list);
}
}
}
cb && cb(list);
if (cb) {
cb(list);
}
});
});
}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"@alcalzone/release-script-plugin-iobroker": "^3.7.2",
"@alcalzone/release-script-plugin-license": "^3.7.0",
"@iobroker/adapter-dev": "^1.3.0",
"@iobroker/testing": "^4.1.3",
"@iobroker/types": "^6.0.11",
"@iobroker/vis-2-widgets-react-dev": "^3.0.7",
"alcalzone-shared": "^4.0.8",
Expand Down

0 comments on commit 8a06484

Please sign in to comment.