elearning/Frontend-Learner/node_modules/eslint-plugin-import-x/lib/utils/read-pkg-up.js

21 lines
457 B
JavaScript
Raw Normal View History

2026-01-13 10:46:40 +07:00
import fs from 'node:fs';
import { pkgUp } from './pkg-up.js';
function stripBOM(str) {
return str.replace(/^\uFEFF/, '');
}
export function readPkgUp(opts) {
const fp = pkgUp(opts);
if (!fp) {
return {};
}
try {
return {
pkg: JSON.parse(stripBOM(fs.readFileSync(fp, { encoding: 'utf8' }))),
path: fp,
};
}
catch {
return {};
}
}
//# sourceMappingURL=read-pkg-up.js.map