MCPcopy Create free account
hub / github.com/openai/plugins / formatCommandPath

Function formatCommandPath

plugins/plugin-eval/src/lib/files.js:103–123  ·  view source on GitHub ↗
(targetPath, options = {})

Source from the content-addressed store, hash-verified

101}
102
103export 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
125export async function walkFiles(rootPath, options = {}) {
126 const files = [];

Callers 10

buildStartCommandFunction · 0.90
normalizeConfigFunction · 0.90
initializeBenchmarkFunction · 0.90
runBenchmarkFunction · 0.90
commandsForGoalFunction · 0.90
createEntryFunction · 0.90
buildWorkflowGuideFunction · 0.90

Calls 1

toPosixPathFunction · 0.85

Tested by

no test coverage detected