Skip to content

Commit

Permalink
feat: Assign pkgVersion and id of all child shim instances when using…
Browse files Browse the repository at this point in the history
… shim.makeSpecializedShim with a ConglomerateShim instance (#1941)
  • Loading branch information
bizob2828 committed Jan 10, 2024
1 parent 7d378aa commit d3e393d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/shim/conglomerate-shim.js
Expand Up @@ -65,7 +65,15 @@ class ConglomerateShim extends Shim {
*/
makeSpecializedShim(type, submodule) {
const ShimClass = SHIM_CLASSES[type]
const shim = new ShimClass(this.agent, this.moduleName, this._resolvedName)
const shim = new ShimClass(
this.agent,
this.moduleName,
this._resolvedName,
null,
this.pkgVersion
)
// associate the parent shim.id with the new submodule
shim.id = this.id
shim._logger = shim._logger.child({ submodule })
return shim
}
Expand Down
6 changes: 6 additions & 0 deletions test/unit/shim/conglomerate-shim.test.js
Expand Up @@ -75,6 +75,12 @@ test('ConglomerateShim', (t) => {
t.equal(shim.moduleName, mod)
t.equal(agent, shim._agent)
t.equal(shim.pkgVersion, version)
function childFn() {}
const childShim = shim.makeSpecializedShim(shim.DATASTORE, childFn)
t.same(shim._agent, childShim._agent)
t.equal(shim.moduleName, childShim.moduleName)
t.equal(shim.pkgVersion, childShim.pkgVersion)
t.equal(shim.id, childShim.id)
t.end()
})
})

0 comments on commit d3e393d

Please sign in to comment.