'use strict';constpath=require('path');constresolveCwd=require('resolve-cwd');constpkgDir=require('pkg-dir');module.exports=filename=>{constglobalDir=pkgDir.sync(path.dirname(filename));constrelativePath=path.relative(globalDir,filename);constpkg=require(path.join(globalDir,'package.json'));constlocalFile=resolveCwd.silent(path.join(pkg.name,relativePath));constlocalNodeModules=path.join(process.cwd(),'node_modules');constfilenameInLocalNodeModules=!path.relative(localNodeModules,filename).startsWith('..');// Use `path.relative()` to detect local package installation,// because __filename's case is inconsistent on Windows// Can use `===` when targeting Node.js 8// See https://github.com/nodejs/node/issues/6624return!filenameInLocalNodeModules&&localFile&&path.relative(localFile,filename)!==''&&require(localFile);};