mirror of
https://gitee.com/HuLaSpark/HuLa.git
synced 2024-11-29 10:18:35 +08:00
21 lines
468 B
TypeScript
21 lines
468 B
TypeScript
//使用path需要按照@types/node依赖
|
|
import path from 'path'
|
|
|
|
/**
|
|
* 获取项目根路径
|
|
* @descrition 末尾不带斜杠
|
|
*/
|
|
export const getRootPath = () => {
|
|
return path.resolve(__dirname, process.cwd())
|
|
}
|
|
|
|
/**
|
|
* 获取项目主路径 如(src)
|
|
* @param mainName - src目录名称(默认: "src")
|
|
* @descrition 末尾不带斜杠
|
|
*/
|
|
export const getSrcPath = (mainName = 'src') => {
|
|
const rootPath = getRootPath()
|
|
return `${rootPath}/${mainName}`
|
|
}
|