2023-12-18 13:12:25 +08:00
|
|
|
'use strict';
|
|
|
|
const path = require('path');
|
|
|
|
const findUp = require('find-up');
|
|
|
|
|
2024-01-16 21:26:16 +08:00
|
|
|
const pkgDir = async cwd => {
|
|
|
|
const filePath = await findUp('package.json', {cwd});
|
|
|
|
return filePath && path.dirname(filePath);
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = pkgDir;
|
|
|
|
// TODO: Remove this for the next major release
|
|
|
|
module.exports.default = pkgDir;
|
2023-12-18 13:12:25 +08:00
|
|
|
|
|
|
|
module.exports.sync = cwd => {
|
2024-01-16 21:26:16 +08:00
|
|
|
const filePath = findUp.sync('package.json', {cwd});
|
|
|
|
return filePath && path.dirname(filePath);
|
2023-12-18 13:12:25 +08:00
|
|
|
};
|