'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));// 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/6624returnlocalFile&&path.relative(localFile,filename)!==''?require(localFile):null;};