Fixing issue with plugin import for datasources - extract the integration correctly.

This commit is contained in:
mike12345567 2022-09-13 12:16:00 +01:00
parent ffed456c9c
commit 781832a52a
2 changed files with 7 additions and 2 deletions

View File

@ -94,11 +94,16 @@ module.exports = {
for (let plugin of plugins) {
if (plugin.name === integration) {
// need to use commonJS require due to its dynamic runtime nature
return getDatasourcePlugin(
const retrieved: any = await getDatasourcePlugin(
plugin.name,
plugin.jsUrl,
plugin.schema?.hash
)
if (retrieved.integration) {
return retrieved.integration
} else {
return retrieved
}
}
}
}

View File

@ -415,7 +415,7 @@ exports.getDatasourcePlugin = async (name, url, hash) => {
const content = await response.text()
fs.writeFileSync(filename, content)
fs.writeFileSync(metadataName, hash)
require(filename)
return require(filename)
} else {
throw new Error(
`Unable to retrieve plugin - reason: ${await response.text()}`