import { parseSource } from '../src/shared/utils/bash-parser.ts';

const cmd = 'cd /c/Users/zhuoz/Desktop/gui && ls -la build* 2>/dev/null || echo "No build directory found"';

// Test 1: just parseSource with timeout guard
console.log('Testing parseSource...');
const start = Date.now();

// Use a worker-like approach: run in a separate microtask with a hard timeout
let result: any = 'TIMEOUT';
let done = false;

// We can't truly timeout sync code in JS, but let's at least see if it returns
try {
  result = parseSource(cmd);
  done = true;
} catch (e) {
  result = 'ERROR: ' + e;
  done = true;
}

const elapsed = Date.now() - start;
console.log('parseSource returned:', done ? 'yes' : 'no', 'time:', elapsed, 'ms');
console.log('result type:', result?.type, 'children:', result?.children?.length);
