2020-11-02 09:51:40 +08:00

17 lines
400 B
JavaScript

const { join } = require('path');
const getCwd = require('./getCwd');
module.exports = (dir) => {
try {
// eslint-disable-next-line
return require(join(getCwd(), 'package.json'));
} catch (error) {
try {
// eslint-disable-next-line
return require(join(dir, 'package.json'));
} catch (err) {
return null;
}
}
};