github-pages-deploy-action/node_modules/pkg-dir/index.js

18 lines
452 B
JavaScript
Raw Normal View History

2020-01-28 13:07:56 +08:00
'use strict';
const path = require('path');
const findUp = require('find-up');
2020-03-31 20:57:48 +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;
2020-01-28 13:07:56 +08:00
module.exports.sync = cwd => {
2020-03-31 20:57:48 +08:00
const filePath = findUp.sync('package.json', {cwd});
return filePath && path.dirname(filePath);
2020-01-28 13:07:56 +08:00
};