From 983666937ef27e7d1fa6aa7343c1db297df9bbfd Mon Sep 17 00:00:00 2001 From: g7vind Date: Sun, 1 Feb 2026 00:20:17 +0530 Subject: [PATCH] fix(sync): fixed the issue of commiting in windows --- docs/releases.md | 12 ++++++++++++ src/commands/sync.ts | 6 ++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/docs/releases.md b/docs/releases.md index 4e54b88..ece9e7a 100644 --- a/docs/releases.md +++ b/docs/releases.md @@ -1,5 +1,17 @@ # Release Notes +## v2.2.3 + +> **Release Date**: 2026-01-31 +> **Focus**: Cross-Platform Compatibility (Sync Command) + +### 🔧 Improvements + +- **Windows Compatibility**: Fixed `sync` command to work correctly on Windows by using `path.basename()` instead of Unix-style path splitting for repository name extraction. +- **Shell Escaping**: Updated shell argument escaping to use double quotes instead of single quotes for better cross-platform compatibility. + +--- + ## v2.2.2 > **Release Date**: 2026-01-18 diff --git a/src/commands/sync.ts b/src/commands/sync.ts index b7b903e..4324402 100644 --- a/src/commands/sync.ts +++ b/src/commands/sync.ts @@ -4,6 +4,7 @@ import chalk from 'chalk'; import inquirer from 'inquirer'; import ora from 'ora'; import { config } from '../storage/config.js'; +import path from 'path'; function sanitizeRepoName(name: string): string { return name.replace(/[^a-zA-Z0-9_-]/g, '-').replace(/--+/g, '-'); @@ -16,9 +17,10 @@ function isValidGitUrl(url: string): boolean { } function escapeShellArg(arg: string): string { - return `'${arg.replace(/'/g, "'\\''")}'`; + return `"${arg.replace(/"/g, '\\"')}"`; } + function isGitInstalled(): boolean { try { execSync('git --version', { stdio: 'ignore' }); @@ -101,7 +103,7 @@ async function setupRemote(workDir: string): Promise { if (createGh) { spinner.start('Creating GitHub repository...'); try { - const rawRepoName = workDir.split('/').pop() || 'leetcode-solutions'; + const rawRepoName = path.basename(workDir) || 'leetcode-solutions'; const repoName = sanitizeRepoName(rawRepoName); execSync(`gh repo create ${repoName} --private --source=. --remote=origin`, { cwd: workDir,