miao-plugin/tools/path.js

16 lines
481 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 根据文件路径计算miao-plugin路径及yunzai路径
* 规避在外部import在非yunzai根目录执行时使用process.cwd()查找文件有可能错误的问题
*/
import * as path from 'path'
import { fileURLToPath } from 'url'
const __dirname = path.dirname(fileURLToPath(import.meta.url))
// miao-plugin根路径
const miaoPath = path.join(__dirname, '..')
// yunzai根路径
const rootPath = path.join(miaoPath, '..', '..')
export { miaoPath, rootPath }