mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-06-30 19:00:57 +08:00
fix(tests): resolve 10 failing tests on Windows (#2307)
- resolve-formatter: stop findProjectRoot walk before os.homedir() to avoid mistaking global dotfiles (e.g. ~/.prettierrc) for a project root - instinct-cli-projects: detect python3/python binary at runtime; skip gracefully when Python 3 is unavailable instead of crashing with null status - command-registry: regenerate COMMAND-REGISTRY.json (was stale) Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
00b443eddb
commit
acd078f59e
@ -9,6 +9,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const os = require('os');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
// ── Caches (per-process, cleared on next hook invocation) ───────────
|
// ── Caches (per-process, cleared on next hook invocation) ───────────
|
||||||
@ -58,8 +59,12 @@ const FORMATTER_PACKAGES = {
|
|||||||
function findProjectRoot(startDir) {
|
function findProjectRoot(startDir) {
|
||||||
if (projectRootCache.has(startDir)) return projectRootCache.get(startDir);
|
if (projectRootCache.has(startDir)) return projectRootCache.get(startDir);
|
||||||
|
|
||||||
|
const homeDir = os.homedir();
|
||||||
let dir = startDir;
|
let dir = startDir;
|
||||||
while (dir !== path.dirname(dir)) {
|
while (dir !== path.dirname(dir)) {
|
||||||
|
// Stop before checking the home directory to avoid treating global
|
||||||
|
// dotfiles (e.g. ~/.prettierrc) as a project root marker.
|
||||||
|
if (dir === homeDir) break;
|
||||||
for (const marker of PROJECT_ROOT_MARKERS) {
|
for (const marker of PROJECT_ROOT_MARKERS) {
|
||||||
if (fs.existsSync(path.join(dir, marker))) {
|
if (fs.existsSync(path.join(dir, marker))) {
|
||||||
projectRootCache.set(startDir, dir);
|
projectRootCache.set(startDir, dir);
|
||||||
|
|||||||
@ -17,6 +17,23 @@ const cliPath = path.join(
|
|||||||
'instinct-cli.py'
|
'instinct-cli.py'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
function detectPython3() {
|
||||||
|
for (const bin of ['python3', 'python']) {
|
||||||
|
const r = spawnSync(bin, ['--version'], { encoding: 'utf8' });
|
||||||
|
if (r.status === 0 && /Python 3/.test(r.stdout + r.stderr)) return bin;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const PYTHON3 = detectPython3();
|
||||||
|
if (!PYTHON3) {
|
||||||
|
console.log('\n=== Testing instinct-cli.py projects maintenance ===\n');
|
||||||
|
console.log(' - skipped: Python 3 not found in PATH');
|
||||||
|
console.log('\nPassed: 0');
|
||||||
|
console.log('Failed: 0');
|
||||||
|
process.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
function test(name, fn) {
|
function test(name, fn) {
|
||||||
try {
|
try {
|
||||||
fn();
|
fn();
|
||||||
@ -101,7 +118,7 @@ function runGit(cwd, args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function runCli(root, args, options = {}) {
|
function runCli(root, args, options = {}) {
|
||||||
return spawnSync('python3', [cliPath, ...args], {
|
return spawnSync(PYTHON3, [cliPath, ...args], {
|
||||||
cwd: options.cwd || repoRoot,
|
cwd: options.cwd || repoRoot,
|
||||||
encoding: 'utf8',
|
encoding: 'utf8',
|
||||||
env: {
|
env: {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user