UNPKG

crootfast

Version:

大前端工程化命令行脚手架

24 lines (21 loc) 645 B
const path = require('path'); /** * 根据 __dirname 设置路径并返回绝对路径。 * @param {string} relativePath 相对于当前文件的路径片段。 * @return {string} 绝对路径。 */ function getPathFromDirname(relativePath) { return path.resolve(__dirname, relativePath); } /** * 根据当前进程的根目录设置路径并返回绝对路径。 * @param {string} relativePath 相对于进程根目录的路径片段。 * @return {string} 绝对路径。 */ function getPathFromRoot(relativePath) { return path.resolve(process.cwd(), relativePath); } module.exports = { getPathFromDirname, getPathFromRoot };