mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-06-11 02:33:10 +08:00
fix: normalize POSIX CLAUDE_PLUGIN_ROOT to Windows path in hook bootstrap (#2139)
Co-authored-by: Matt Van Horn <455140+mvanhorn@users.noreply.github.com>
This commit is contained in:
@@ -31,6 +31,20 @@ function passthrough(raw, result) {
|
||||
}
|
||||
}
|
||||
|
||||
function normalizePluginRootForPlatform(rootDir, platform = process.platform) {
|
||||
if (platform !== 'win32' || typeof rootDir !== 'string') {
|
||||
return rootDir;
|
||||
}
|
||||
|
||||
const match = rootDir.match(/^\/([a-zA-Z])(?:\/(.*))?$/);
|
||||
if (!match) {
|
||||
return rootDir;
|
||||
}
|
||||
|
||||
const [, driveLetter, rest = ''] = match;
|
||||
return `${driveLetter.toUpperCase()}:/${rest}`;
|
||||
}
|
||||
|
||||
function resolveTarget(rootDir, relPath) {
|
||||
const resolvedRoot = path.resolve(rootDir);
|
||||
const resolvedTarget = path.resolve(rootDir, relPath);
|
||||
@@ -110,7 +124,9 @@ function spawnShell(rootDir, relPath, raw, args) {
|
||||
function main() {
|
||||
const [, , mode, relPath, ...args] = process.argv;
|
||||
const raw = readStdinRaw();
|
||||
const rootDir = process.env.CLAUDE_PLUGIN_ROOT || process.env.ECC_PLUGIN_ROOT;
|
||||
const rootDir = normalizePluginRootForPlatform(
|
||||
process.env.CLAUDE_PLUGIN_ROOT || process.env.ECC_PLUGIN_ROOT
|
||||
);
|
||||
|
||||
if (!mode || !relPath || !rootDir) {
|
||||
process.stdout.write(raw);
|
||||
@@ -150,4 +166,11 @@ function main() {
|
||||
process.exit(Number.isInteger(result.status) ? result.status : 0);
|
||||
}
|
||||
|
||||
main();
|
||||
if (require.main === module) {
|
||||
main();
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
main,
|
||||
normalizePluginRootForPlatform,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user