fastify-plugin
Advanced tools
Comparing version 2.3.1 to 2.3.2
{ | ||
"name": "fastify-plugin", | ||
"version": "2.3.1", | ||
"version": "2.3.2", | ||
"description": "Plugin helper for Fastify", | ||
@@ -5,0 +5,0 @@ "main": "plugin.js", |
@@ -84,2 +84,11 @@ 'use strict' | ||
function tryGetPath (p) { | ||
var pkgPath | ||
try { | ||
pkgPath = resolvePkgPath(p) | ||
} catch (_) { | ||
} | ||
return pkgPath | ||
} | ||
function checkVersion (version, pluginName) { | ||
@@ -90,17 +99,19 @@ if (typeof version !== 'string') { | ||
// TODO refactor this check and move it inside Fastify itself. | ||
// TODO refactor this check and move it inside Fastify itself. https://github.com/fastify/fastify/issues/2507 | ||
var fastifyVersion | ||
var pkgPath | ||
if (require.main && require.main.filename) { | ||
// We need to dynamically compute this to support yarn pnp | ||
pkgPath = tryGetPath(require.main.filename) | ||
} | ||
if (!pkgPath && process.argv[1]) { | ||
// We need this to support native ESM context | ||
pkgPath = tryGetPath(process.argv[1]) | ||
} | ||
if (!pkgPath) { | ||
// In bundlers, there is no require.main.filename so we go ahead and require directly | ||
pkgPath = 'fastify/package.json' | ||
} | ||
try { | ||
var pkgPath | ||
if (require.main && require.main.filename) { | ||
// We need to dynamically compute this to support yarn pnp | ||
pkgPath = resolvePkgPath(require.main.filename) | ||
} else if (process.argv[1]) { | ||
// We need this to support native ESM context | ||
pkgPath = resolvePkgPath(process.argv[1]) | ||
} else { | ||
// In bundlers, there is no require.main.filename so we go ahead and require directly | ||
pkgPath = 'fastify/package.json' | ||
} | ||
fastifyVersion = semver.coerce(require(pkgPath).version) | ||
@@ -107,0 +118,0 @@ } catch (_) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27964
18
678