Skip to content

Commit

Permalink
fix(ignore): fix external definition generator
Browse files Browse the repository at this point in the history
  • Loading branch information
Koenkk committed Jan 19, 2025
1 parent db5c39b commit dc858cf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/lib/generateDefinition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ type DefinitionWithZigbeeModel = DefinitionWithExtend & {zigbeeModel: string[]};

function generateSource(definition: DefinitionWithZigbeeModel, generatedExtend: GeneratedExtend[]): string {
const imports = [...new Set(generatedExtend.map((e) => e.lib ?? 'modernExtend'))];
const importsStr = imports.map((e) => `const * as ${e == 'modernExtend' ? 'm' : e} = require('zigbee-herdsman-converters/lib/${e}');`).join('\n');
const importsStr = imports.map((e) => `const ${e == 'modernExtend' ? 'm' : e} = require('zigbee-herdsman-converters/lib/${e}');`).join('\n');
return `${importsStr}
const definition = {
Expand Down
14 changes: 7 additions & 7 deletions test/generateDefinition.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ describe('GenerateDefinition', () => {
],
},
externalDefintionSource: `
const * as m = require('zigbee-herdsman-converters/lib/modernExtend');
const m = require('zigbee-herdsman-converters/lib/modernExtend');
const definition = {
zigbeeModel: ['combo'],
Expand Down Expand Up @@ -143,7 +143,7 @@ module.exports = definition;
],
},
externalDefintionSource: `
const * as m = require('zigbee-herdsman-converters/lib/modernExtend');
const m = require('zigbee-herdsman-converters/lib/modernExtend');
const definition = {
zigbeeModel: ['combo'],
Expand Down Expand Up @@ -189,7 +189,7 @@ module.exports = definition;
2: [['msTemperatureMeasurement', [reportingItem('measuredValue', 10, repInterval.HOUR, 100)]]],
},
externalDefintionSource: `
const * as m = require('zigbee-herdsman-converters/lib/modernExtend');
const m = require('zigbee-herdsman-converters/lib/modernExtend');
const definition = {
zigbeeModel: ['combo'],
Expand Down Expand Up @@ -259,7 +259,7 @@ module.exports = definition;
},
configureReporting: {},
externalDefintionSource: `
const * as m = require('zigbee-herdsman-converters/lib/modernExtend');
const m = require('zigbee-herdsman-converters/lib/modernExtend');
const definition = {
zigbeeModel: ['combo'],
Expand Down Expand Up @@ -329,7 +329,7 @@ module.exports = definition;
},
configureReporting: {},
externalDefintionSource: `
const * as m = require('zigbee-herdsman-converters/lib/modernExtend');
const m = require('zigbee-herdsman-converters/lib/modernExtend');
const definition = {
zigbeeModel: ['combo'],
Expand Down Expand Up @@ -405,7 +405,7 @@ module.exports = definition;
},
configureReporting: [],
externalDefintionSource: `
const * as philips = require('zigbee-herdsman-converters/lib/philips');
const philips = require('zigbee-herdsman-converters/lib/philips');
const definition = {
zigbeeModel: ['combo'],
Expand Down Expand Up @@ -484,7 +484,7 @@ module.exports = definition;
],
},
externalDefintionSource: `
const * as m = require('zigbee-herdsman-converters/lib/modernExtend');
const m = require('zigbee-herdsman-converters/lib/modernExtend');
const definition = {
zigbeeModel: ['combo'],
Expand Down

0 comments on commit dc858cf

Please sign in to comment.