Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
get htmlToMobiledocConverter() {
try {
return require('@tryghost/html-to-mobiledoc').toMobiledoc;
} catch (err) {
if (process.versions.node.startsWith('v6.')) {
// NOTE: When Node v6 is dropped this code block should be removed
return () => {
throw new common.errors.InternalServerError({
message: 'Unable to convert from source HTML to Mobiledoc',
context: 'The html-to-mobiledoc package was not installed',
help: 'Please upgrade to Node.js v10',
code: 'HTML_TO_MOBILEDOC_INSTALLATION',
err: err
});
};
} else {
return () => {
throw new common.errors.InternalServerError({
message: 'Unable to convert from source HTML to Mobiledoc',
get htmlToMobiledocConverter() {
try {
return require('@tryghost/html-to-mobiledoc').toMobiledoc;
} catch (err) {
return () => {
throw new common.errors.InternalServerError({
message: 'Unable to convert from source HTML to Mobiledoc',
context: 'The html-to-mobiledoc package was not installed',
help: 'Please review any errors from the install process by checking the Ghost logs',
code: 'HTML_TO_MOBILEDOC_INSTALLATION',
err: err
});
};
}
}
};