UNPKG

448 BJavaScriptView Raw
1const path = require('path');
2const getRootDir = require('./getRootDir');
3
4module.exports = function underPath(underpath, subpath) {
5 const rootPath = getRootDir();
6 const mapping = {
7 root: rootPath, // 项目的根目录下
8 bin: path.join(rootPath, 'bin'), // 项目的 bin 目录下
9 cur: process.cwd(), // 执行命令时的的当下目录
10 };
11
12 return path.resolve(path.join(mapping[underpath] || underpath, subpath || '.'));
13};