summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrew Ritter <drew@ritter.dev>2026-02-05 16:37:31 -0800
committerDrew Ritter <drew@ritter.dev>2026-02-05 17:21:25 -0800
commit0771fd7cd1fd73b8e8da2d3374d4f3797b2ad1bd (patch)
treef51a0918f64ff93b6b431a1393857d6c4aa0ad37
parentbcccc692717f52be444b451e02e9e24760bd34be (diff)
Fix path resolution and symlink removal in Codex installer
Use fileURLToPath() instead of manual URL pathname parsing to correctly handle paths with spaces and special characters on all platforms. Replace execSync rm/rmdir with fs.unlinkSync for stale symlink removal. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
-rw-r--r--.codex/install-codex.mjs10
1 files changed, 6 insertions, 4 deletions
diff --git a/.codex/install-codex.mjs b/.codex/install-codex.mjs
index 5db43e3..a5edb3c 100644
--- a/.codex/install-codex.mjs
+++ b/.codex/install-codex.mjs
@@ -4,8 +4,9 @@
// Creates a symlink from ~/.agents/skills/superpowers → repo skills/
// and updates ~/.codex/AGENTS.md with a gatekeeper block.
-import { existsSync, readFileSync, writeFileSync, mkdirSync, symlinkSync, lstatSync, readlinkSync } from 'fs';
-import { join, resolve } from 'path';
+import { existsSync, readFileSync, writeFileSync, mkdirSync, symlinkSync, lstatSync, readlinkSync, unlinkSync } from 'fs';
+import { join, resolve, dirname } from 'path';
+import { fileURLToPath } from 'url';
import { homedir, platform } from 'os';
import { execSync } from 'child_process';
@@ -13,7 +14,8 @@ const home = homedir();
const isWindows = platform() === 'win32';
// Paths
-const repoSkillsDir = resolve(new URL('.', import.meta.url).pathname.replace(/^\/([A-Z]:)/i, '$1'), '..', 'skills');
+const __dirname = dirname(fileURLToPath(import.meta.url));
+const repoSkillsDir = resolve(__dirname, '..', 'skills');
const agentsSkillsDir = join(home, '.agents', 'skills');
const symlinkPath = join(agentsSkillsDir, 'superpowers');
const agentsMdPath = join(home, '.codex', 'AGENTS.md');
@@ -52,7 +54,7 @@ function createSymlink() {
return;
}
console.log(`! Existing symlink points to ${target}, updating to ${repoSkillsDir}`);
- execSync(isWindows ? `rmdir "${symlinkPath}"` : `rm "${symlinkPath}"`);
+ unlinkSync(symlinkPath);
} else {
console.error(`✗ ${symlinkPath} already exists and is not a symlink.`);
console.error(` Remove it manually and re-run the installer.`);