Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function createSiteAddon({ addonName, settings, accessToken, siteData, error }, logger) {
let addonResponse
try {
// TODO update to https://open-api.netlify.com/#/default/createServiceInstance
addonResponse = await createAddon(settings, accessToken)
} catch (e) {
error(e.message)
}
if (addonResponse.code === 404) {
logger(`No add-on "${addonName}" found. Please double check your add-on name and try again`)
return false
}
logger(`Add-on "${addonName}" created for ${siteData.name}`)
if (addonResponse.config && addonResponse.config.message) {
logger()
logger(`${addonResponse.config.message}`)
}
return addonResponse
}
async function actuallyCreateSiteAddon({
addonName,
settings,
accessToken,
siteData
}) {
const addonResponse = await createAddon(settings, accessToken);
if (addonResponse.code === 404) {
console.log(
`No add-on "${addonName}" found. Please double check your add-on name and try again`
);
return false;
}
console.log(`Add-on "${addonName}" created for ${siteData.name}`);
if (addonResponse.config && addonResponse.config.message) {
console.log();
console.log(`${addonResponse.config.message}`);
}
return addonResponse;
}
async function actuallyCreateSiteAddon({ addonName, settings, accessToken, siteData }) {
const addonResponse = await createAddon(settings, accessToken)
if (addonResponse.code === 404) {
console.log(`No add-on "${addonName}" found. Please double check your add-on name and try again`)
return false
}
console.log(`Add-on "${addonName}" created for ${siteData.name}`)
if (addonResponse.config && addonResponse.config.message) {
console.log()
console.log(`${addonResponse.config.message}`)
}
return addonResponse
}