Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function checkVersion (version) {
if (typeof version !== 'string') {
throw new TypeError(`fastify-plugin expects a version string, instead got '${typeof version}'`)
}
var fastifyVersion
try {
fastifyVersion = require('fastify/package.json').version.replace(/-rc\.\d+/, '')
} catch (_) {
console.info('fastify not found, proceeding anyway')
}
if (fastifyVersion && !semver.satisfies(fastifyVersion, version)) {
throw new Error(`fastify-plugin - expected '${version}' fastify version, '${fastifyVersion}' is installed`)
}
}