(targetPath, options = {})
| 101 | } |
| 102 | |
| 103 | export function formatCommandPath(targetPath, options = {}) { |
| 104 | const absoluteTargetPath = path.resolve(targetPath); |
| 105 | const cwd = path.resolve(options.cwd || process.cwd()); |
| 106 | const homeDir = path.resolve(options.homeDir || os.homedir()); |
| 107 | |
| 108 | if (absoluteTargetPath === homeDir) { |
| 109 | return "~"; |
| 110 | } |
| 111 | |
| 112 | const relativeToHome = path.relative(homeDir, absoluteTargetPath); |
| 113 | if (relativeToHome && !relativeToHome.startsWith("..") && !path.isAbsolute(relativeToHome)) { |
| 114 | return `~/${toPosixPath(relativeToHome)}`; |
| 115 | } |
| 116 | |
| 117 | const relativeToCwd = path.relative(cwd, absoluteTargetPath) || "."; |
| 118 | if (!relativeToCwd.startsWith("..") && !path.isAbsolute(relativeToCwd)) { |
| 119 | return toPosixPath(relativeToCwd); |
| 120 | } |
| 121 | |
| 122 | return toPosixPath(absoluteTargetPath); |
| 123 | } |
| 124 | |
| 125 | export async function walkFiles(rootPath, options = {}) { |
| 126 | const files = []; |
no test coverage detected