'use strict';1exports.__esModule = true;23const fs = require('fs');4const pkgUp = require('./pkgUp').default;56function stripBOM(str) {7return str.replace(/^\uFEFF/, '');8}910/**11* Derived significantly from [email protected]. See license below.12*13* @copyright Sindre Sorhus14* MIT License15*16* Copyright (c) Sindre Sorhus <[email protected]> (https://sindresorhus.com)17*18* Permission is hereby granted, free of charge, to any person obtaining a copy19* of this software and associated documentation files (the "Software"), to deal20* in the Software without restriction, including without limitation the rights21* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell22* copies of the Software, and to permit persons to whom the Software is23* furnished to do so, subject to the following conditions:24*25* The above copyright notice and this permission notice shall be included in26* all copies or substantial portions of the Software.27*28* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR29* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,30* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE31* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER32* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,33* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN34* THE SOFTWARE.35*/36exports.default = function readPkgUp(opts) {37const fp = pkgUp(opts);3839if (!fp) {40return {};41}4243try {44return {45pkg: JSON.parse(stripBOM(fs.readFileSync(fp, { encoding: 'utf-8' }))),46path: fp,47};48} catch (e) {49return {};50}51};525354