(prefix?: string)
| 44 | */ |
| 45 | |
| 46 | export const formattedPrefix = (prefix?: string): string => { |
| 47 | // 如果没传,则默认为空 |
| 48 | if (!prefix) return '' |
| 49 | |
| 50 | let _prefix = prefix |
| 51 | |
| 52 | // 如果开头无需/ |
| 53 | if (_prefix.startsWith('/')) { |
| 54 | _prefix = _prefix.slice(1) |
| 55 | } |
| 56 | |
| 57 | // 如果结尾需要/ |
| 58 | if (!_prefix.endsWith('/')) { |
| 59 | _prefix = `${_prefix}/` |
| 60 | } |
| 61 | |
| 62 | return _prefix |
| 63 | } |
| 64 | |
| 65 | export const resolvePluginPath = (pluginPath: string) => { |
| 66 | const pluginLocalPath = path.resolve(process.cwd(), pluginPath) |