first commit
This commit is contained in:
21
node_modules/eslint-plugin-import-x/lib/utils/read-pkg-up.js
generated
vendored
Normal file
21
node_modules/eslint-plugin-import-x/lib/utils/read-pkg-up.js
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
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
|
||||
Reference in New Issue
Block a user