Skip to content

Commit 37f2d0b

Browse files
ralyodioclaude
andcommitted
fix(chocolatey): use path.dirname() instead of string manipulation for cross-platform compatibility
The previous code used lastIndexOf('/') to extract directory paths, which fails on Windows where path.join() uses backslashes. This caused `mkdir -p ""` errors when writing package files. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 249d56c commit 37f2d0b

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

scripts/lib/package-managers/chocolatey.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
*/
77

88
import { execSync } from 'node:child_process';
9-
import { mkdtempSync, writeFileSync, rmSync } from 'node:fs';
10-
import { join } from 'node:path';
9+
import { mkdtempSync, writeFileSync, rmSync, mkdirSync } from 'node:fs';
10+
import { join, dirname } from 'node:path';
1111
import { tmpdir } from 'node:os';
1212
import { BasePackageManager } from './base.js';
1313
import type { ReleaseInfo, SubmissionResult } from './types.js';
@@ -215,10 +215,9 @@ https://github.com/profullstack/pairux.com
215215
// Write package files
216216
for (const [filePath, content] of Object.entries(files)) {
217217
const fullPath = join(tempDir, filePath);
218-
const dir = fullPath.substring(0, fullPath.lastIndexOf('/'));
219-
if (dir !== tempDir) {
220-
execSync(`mkdir -p "${dir}"`, { cwd: tempDir });
221-
}
218+
const dir = dirname(fullPath);
219+
// Create parent directory if it doesn't exist (no-op if it does)
220+
mkdirSync(dir, { recursive: true });
222221
writeFileSync(fullPath, content, 'utf-8');
223222
}
224223

0 commit comments

Comments
 (0)