mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-04-05 08:43:29 +08:00
fix: normalize bash metadata paths on windows
This commit is contained in:
@@ -8,7 +8,7 @@ const assert = require('assert');
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
const { spawn, spawnSync } = require('child_process');
|
const { execFileSync, spawn, spawnSync } = require('child_process');
|
||||||
|
|
||||||
function toBashPath(filePath) {
|
function toBashPath(filePath) {
|
||||||
if (process.platform !== 'win32') {
|
if (process.platform !== 'win32') {
|
||||||
@@ -25,12 +25,34 @@ function fromBashPath(filePath) {
|
|||||||
return filePath;
|
return filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
const match = String(filePath).match(/^\/([A-Za-z])\/(.*)$/);
|
const rawPath = String(filePath || '');
|
||||||
if (!match) {
|
if (!rawPath) {
|
||||||
return filePath;
|
return rawPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
return `${match[1].toUpperCase()}:\\${match[2].replace(/\//g, '\\')}`;
|
try {
|
||||||
|
return execFileSync(
|
||||||
|
'bash',
|
||||||
|
['-lc', 'cygpath -w -- "$1"', 'bash', rawPath],
|
||||||
|
{ stdio: ['ignore', 'pipe', 'ignore'] }
|
||||||
|
)
|
||||||
|
.toString()
|
||||||
|
.trim();
|
||||||
|
} catch {
|
||||||
|
// Fall back to common Git Bash path shapes when cygpath is unavailable.
|
||||||
|
}
|
||||||
|
|
||||||
|
const match = rawPath.match(/^\/(?:cygdrive\/)?([A-Za-z])\/(.*)$/)
|
||||||
|
|| rawPath.match(/^\/\/([A-Za-z])\/(.*)$/);
|
||||||
|
if (match) {
|
||||||
|
return `${match[1].toUpperCase()}:\\${match[2].replace(/\//g, '\\')}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (/^[A-Za-z]:\//.test(rawPath)) {
|
||||||
|
return rawPath.replace(/\//g, '\\');
|
||||||
|
}
|
||||||
|
|
||||||
|
return rawPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
function sleepMs(ms) {
|
function sleepMs(ms) {
|
||||||
|
|||||||
Reference in New Issue
Block a user