vuepress-plugin-helper-live2d
Version:
VuePress集成Live2D看板娘. Live2D plugin for VuePress.
25 lines (16 loc) • 510 B
JavaScript
/**
* @description Resolve the path of provided package name
*/
const path = require('path');
/**
* Resolve the package path according to provided package name
* @param {String} packageName Package need to be resolved
* @return {String} If detected the package, the path; if not, null
*/
module.exports = function getNodeModulePath(packageName) {
try {
return path.dirname(require.resolve(`${packageName}/package.json`));
} catch (e) {
return null;
}
};