Skip to content

Commit 0b77406

Browse files
committed
Fix 'Cannot find module ./manifest.json' (#314)
1 parent 7a0372b commit 0b77406

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"lib/driver/conbee.js",
5858
"lib/driver/xbee.js",
5959
"lib/driver/zstack.js",
60+
"lib/constants.js",
6061
"lib/index.js",
6162
"lib/manifest.json",
6263
"lib/zb-adapter.js",

src/constants.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/**
2+
*
3+
* ZigbeeAdapter - Adapter which manages Zigbee devices.
4+
*
5+
* This Source Code Form is subject to the terms of the Mozilla Public
6+
* License, v. 2.0. If a copy of the MPL was not distributed with this
7+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.*
8+
*/
9+
10+
export const PACKAGE_ID = 'zigbee-adapter';

src/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
'use strict';
1111

1212
const { Database } = require('gateway-addon');
13-
const manifest = require('./manifest.json');
13+
const { PACKAGE_ID } = require('./constants');
1414
const SerialProber = require('serial-prober');
1515
const { Zigbee2MqttDriver } = require('./zigbee2mqtt/zigbee2mqtt-driver');
1616
const SerialPort = require('serialport');
@@ -189,7 +189,7 @@ async function loadZigbeeAdapters(addonManager, _, errorCallback) {
189189

190190
let config = {};
191191
// Attempt to move to new config format
192-
const db = new Database(manifest.id);
192+
const db = new Database(PACKAGE_ID);
193193
await db
194194
.open()
195195
.then(() => {
@@ -277,14 +277,14 @@ async function loadZigbeeAdapters(addonManager, _, errorCallback) {
277277
SerialProber.listAll()
278278
.then(() => {
279279
if (!zigbee2mqttConfigured) {
280-
errorCallback(manifest.id, 'No Zigbee dongle found');
280+
errorCallback(PACKAGE_ID, 'No Zigbee dongle found');
281281
} else {
282282
console.debug('No Zigbee dongle found');
283283
}
284284
})
285285
.catch((err) => {
286286
if (!zigbee2mqttConfigured) {
287-
errorCallback(manifest.id, err);
287+
errorCallback(PACKAGE_ID, err);
288288
} else {
289289
console.debug(`Could not probe serial ports: ${err}`);
290290
}
@@ -314,7 +314,7 @@ async function loadZigbeeAdapters(addonManager, _, errorCallback) {
314314
})
315315
.catch((err) => {
316316
if (!zigbee2mqttConfigured) {
317-
errorCallback(manifest.id, err);
317+
errorCallback(PACKAGE_ID, err);
318318
} else {
319319
console.debug(`Could not load serial drivers: ${err}`);
320320
}

src/zb-adapter.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
'use strict';
1111

1212
const fs = require('fs');
13-
const manifest = require('./manifest.json');
13+
const { PACKAGE_ID } = require('./constants');
1414
const mkdirp = require('mkdirp');
1515
const os = require('os');
1616
const path = require('path');
@@ -67,7 +67,7 @@ class ZigbeeAdapter extends Adapter {
6767
// retrieve the serial number from the dongle. So we
6868
// set it to zb-unknown here, and fix things up later
6969
// just before we call addAdapter.
70-
super(addonManager, 'zb-unknown', manifest.id);
70+
super(addonManager, 'zb-unknown', PACKAGE_ID);
7171
this.config = config;
7272
this.driver = driver;
7373
console.log('this.driver =', driver);

0 commit comments

Comments
 (0)