Skip to content

Commit cf93ed0

Browse files
DevRohit06claude
andcommitted
fix: resolve Windows compatibility issues across CLI
- Remove unsupported --force-local tar flag for Windows bsdtar - Replace process.env.HOME with os.homedir() in info and doctor commands - Use 'python' instead of 'python3' on Windows for preview fallback - Bump version to 1.4.2 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent fe71abe commit cf93ed0

5 files changed

Lines changed: 13 additions & 10 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@litodocs/cli",
3-
"version": "1.4.1",
3+
"version": "1.4.2",
44
"description": "Beautiful documentation sites from Markdown. Fast, simple, and open-source.",
55
"type": "module",
66
"bin": {

src/commands/doctor.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { existsSync, readFileSync, readdirSync, statSync } from 'fs';
22
import { resolve, join, extname } from 'path';
3+
import { homedir } from 'os';
34
import { intro, outro, log, spinner } from '@clack/prompts';
45
import pc from 'picocolors';
56
import { validateConfig } from '../core/config-validator.js';
@@ -257,7 +258,7 @@ async function checkCommonIssues(inputPath) {
257258
}
258259

259260
async function checkTemplateCache() {
260-
const cacheDir = join(process.env.HOME || '~', '.lito', 'templates');
261+
const cacheDir = join(homedir(), '.lito', 'templates');
261262

262263
if (!existsSync(cacheDir)) {
263264
return {

src/commands/info.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { existsSync, readFileSync, readdirSync, statSync } from 'fs';
22
import { resolve, join, extname } from 'path';
3+
import { homedir } from 'os';
34
import { intro, outro, log } from '@clack/prompts';
45
import pc from 'picocolors';
56
import { TEMPLATE_REGISTRY } from '../core/template-registry.js';
@@ -137,7 +138,7 @@ export async function infoCommand(options) {
137138
log.message(` ${pc.cyan('Node.js:')} ${process.version}`);
138139
log.message(` ${pc.cyan('Platform:')} ${process.platform}`);
139140

140-
const cacheDir = join(process.env.HOME || '~', '.lito', 'templates');
141+
const cacheDir = join(homedir(), '.lito', 'templates');
141142
if (existsSync(cacheDir)) {
142143
const cached = readdirSync(cacheDir).length;
143144
log.message(` ${pc.cyan('Cached templates:')} ${cached}`);

src/commands/preview.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ export async function previewCommand(options) {
7171
} catch (serveError) {
7272
// Fallback to Python's http.server if serve isn't available
7373
try {
74-
await execa('python3', ['-m', 'http.server', port, '-d', outputPath], {
74+
const pythonCmd = process.platform === 'win32' ? 'python' : 'python3';
75+
await execa(pythonCmd, ['-m', 'http.server', port, '-d', outputPath], {
7576
stdio: 'inherit',
7677
cwd: process.cwd(),
7778
});

src/core/template-fetcher.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,13 @@ export async function fetchGitHubTemplate(owner, repo, ref) {
123123

124124
// Use tar to extract (available on all Unix systems and modern Windows)
125125
const { execa } = await import('execa');
126-
const isWin = process.platform === 'win32';
126+
// Use forward slashes on Windows to avoid bsdtar issues with drive letters (C:)
127+
const tarPath = tempTarPath.replace(/\\/g, '/');
128+
const extractPath = cachePath.replace(/\\/g, '/');
127129
const tarArgs = [
128-
'-xzf', isWin ? tempTarPath.replace(/\\/g, '/') : tempTarPath,
129-
'-C', isWin ? cachePath.replace(/\\/g, '/') : cachePath,
130-
'--strip-components=1',
131-
// On Windows, GNU tar misinterprets drive letters (C:) as remote hosts
132-
...(isWin ? ['--force-local'] : [])
130+
'-xzf', tarPath,
131+
'-C', extractPath,
132+
'--strip-components=1'
133133
];
134134
await execa('tar', tarArgs);
135135

0 commit comments

Comments
 (0)