fix: only remove toolshim paths that we know of to preserve full paths to extension binaries (#2325)
This commit is contained in:
@@ -167,9 +167,25 @@ export async function replaceWithShims(cmd: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function removeShims(cmd: string) {
|
export function removeShims(cmd: string) {
|
||||||
const segments = cmd.split('/');
|
// Only remove shims if the path matches our known shim patterns
|
||||||
// Filter out any empty segments (which can happen with trailing slashes)
|
const shimPatterns = [
|
||||||
const nonEmptySegments = segments.filter((segment) => segment.length > 0);
|
/\/goose-shims\/goosed$/,
|
||||||
// Return the last segment or empty string if there are no segments
|
/\/goose-shims\/jbang$/,
|
||||||
return nonEmptySegments.length > 0 ? nonEmptySegments[nonEmptySegments.length - 1] : '';
|
/\/goose-shims\/npx$/,
|
||||||
|
/\/goose-shims\/uvx$/,
|
||||||
|
];
|
||||||
|
|
||||||
|
// Check if the command matches any shim pattern
|
||||||
|
const isShim = shimPatterns.some((pattern) => pattern.test(cmd));
|
||||||
|
|
||||||
|
if (isShim) {
|
||||||
|
const segments = cmd.split('/');
|
||||||
|
// Filter out any empty segments (which can happen with trailing slashes)
|
||||||
|
const nonEmptySegments = segments.filter((segment) => segment.length > 0);
|
||||||
|
// Return the last segment or empty string if there are no segments
|
||||||
|
return nonEmptySegments.length > 0 ? nonEmptySegments[nonEmptySegments.length - 1] : '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// If it's not a shim, return the original command
|
||||||
|
return cmd;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user