@iobroker/js-controller-cli 4.0.0-alpha.46-20220119-9e487e55 → 4.0.0-alpha.47-20220120-7bad8e08

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.
@@ -11,7 +11,6 @@ module.exports = class CLICompact extends CLICommand {
11
11
  super(options);
12
12
  this.config = fs.readJSONSync(tools.getConfigFileName());
13
13
  }
14
-
15
14
  /**
16
15
  * Executes a command
17
16
  * @param {any[]} args
@@ -283,24 +283,19 @@ module.exports = class CLIHost extends CLICommand {
283
283
  * @param {any} objects The objects DB to use
284
284
  * @param {any} instance The instance object
285
285
  * @param {string} newHostname The new hostname the instance should be running on
286
+ * @return Promise<void>
286
287
  */
287
- function changeInstanceHost(objects, instance, newHostname) {
288
- return new Promise(resolve => {
289
- const oldInstanceHost = instance.common.host;
290
- instance.from = getObjectFrom();
291
- instance.ts = Date.now();
292
- instance.common.host = newHostname;
293
- // and save it
294
- objects
295
- .setObjectAsync(instance._id, instance)
296
- .then(() => {
297
- CLI.success.instanceHostChanged(instance._id, oldInstanceHost, newHostname);
298
- resolve();
299
- })
300
- .catch(err => {
301
- CLI.error.cannotChangeObject(instance._id, err.message);
302
- // resolve anyways, we don't want to cause errors
303
- resolve();
304
- });
305
- });
288
+ async function changeInstanceHost(objects, instance, newHostname) {
289
+ const oldInstanceHost = instance.common.host;
290
+ instance.from = getObjectFrom();
291
+ instance.ts = Date.now();
292
+ instance.common.host = newHostname;
293
+ // and save it
294
+ try {
295
+ await objects.setObjectAsync(instance._id, instance);
296
+ CLI.success.instanceHostChanged(instance._id, oldInstanceHost, newHostname);
297
+ } catch (e) {
298
+ CLI.error.cannotChangeObject(instance._id, e.message);
299
+ // resolve anyways, we don't want to cause errors
300
+ }
306
301
  }
@@ -469,7 +469,7 @@ module.exports = class CLIObjects extends CLICommand {
469
469
  input: process.stdin,
470
470
  output: process.stdout
471
471
  });
472
- rl.question(result.length + ' object(s) will be deleted. Are you sure? [y/N]: ', answer => {
472
+ rl.question(`${result.length} object(s) will be deleted. Are you sure? [y/N]: `, answer => {
473
473
  rl.close();
474
474
  if (
475
475
  answer === 'y' ||
@@ -491,21 +491,19 @@ module.exports = class CLIObjects extends CLICommand {
491
491
  });
492
492
  } else {
493
493
  // only one object
494
- objects.delObject(id, err => {
494
+ objects.delObject(id, async err => {
495
495
  if (err) {
496
496
  CLI.error.objectNotFound(id, err);
497
- return void callback(3);
497
+ callback(3);
498
498
  } else {
499
- tools
500
- .removeIdFromAllEnums(objects, id)
501
- .then(() => {
502
- CLI.success.objectDeleted(id);
503
- return void callback();
504
- })
505
- .catch(e => {
506
- CLI.error.cannotDeleteObjectFromEnums(id, e.message);
507
- return void callback(3);
508
- });
499
+ try {
500
+ await tools.removeIdFromAllEnums(objects, id);
501
+ CLI.success.objectDeleted(id);
502
+ callback();
503
+ } catch (e) {
504
+ CLI.error.cannotDeleteObjectFromEnums(id, e.message);
505
+ callback(3);
506
+ }
509
507
  }
510
508
  });
511
509
  }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@iobroker/js-controller-cli",
3
- "version": "4.0.0-alpha.46-20220119-9e487e55",
3
+ "version": "4.0.0-alpha.47-20220120-7bad8e08",
4
4
  "engines": {
5
5
  "node": ">=12.0.0"
6
6
  },
7
7
  "dependencies": {
8
- "@iobroker/js-controller-common": "4.0.0-alpha.46-20220119-9e487e55",
9
- "@iobroker/js-controller-common-db": "4.0.0-alpha.46-20220119-9e487e55",
8
+ "@iobroker/js-controller-common": "4.0.0-alpha.47-20220120-7bad8e08",
9
+ "@iobroker/js-controller-common-db": "4.0.0-alpha.47-20220120-7bad8e08",
10
10
  "chokidar": "^3.5.2",
11
11
  "daemonize2": "^0.4.2",
12
12
  "debug": "^4.3.3",
@@ -38,5 +38,5 @@
38
38
  "lib/",
39
39
  "index.js"
40
40
  ],
41
- "gitHead": "e081e38bf6d24e767e16a0bb5a8d8202f65a9302"
41
+ "gitHead": "1b9bfb430be9ce5a823a9dcd91f612a216281f4f"
42
42
  }