Skip to content

check command finds no files on Windows — hardcoded "/" separator in collectFiles path containment check #1

Description

@gotoayman4

Bug

Running rtlify-ai check on Windows always prints No .js/.jsx/.ts/.tsx files found. even in a project full of .ts/.tsx files. The scan silently becomes a no-op, and since the command exits 0, CI-style usage on Windows passes without auditing anything.

Environment

  • rtlify-ai 0.3.1 (also present in current main)
  • Windows 11, Node 22, pwsh

Reproduction

mkdir repro; cd repro
"const x = 'left';" | Out-File -Encoding utf8 App.tsx
npx rtlify-ai check
# Output: No .js/.jsx/.ts/.tsx files found.

The same project scans fine on Linux/macOS.

Cause

In src/cli.ts, collectFiles() verifies that resolved paths stay inside the project root using a hardcoded POSIX separator:

if (!real.startsWith(projectRoot + "/") && real !== projectRoot) continue;

On Windows, realpath() and join() return backslash paths (e.g. C:\repro\App.tsx), while projectRoot + "/" produces C:\repro/. The startsWith check is therefore always false, so every entry — files and directories alike — is skipped and the walker returns an empty list.

Suggested fix

Use a platform-aware containment check instead of string concatenation, e.g. with path.relative:

import { relative, isAbsolute } from "node:path";

const rel = relative(projectRoot, real);
if (rel.startsWith("..") || isAbsolute(rel)) continue;

Alternatives: real.startsWith(projectRoot + path.sep), or normalizing both sides to POSIX separators via path.normalize() / replacing \ with / before comparing. path.relative is the most robust since it also handles drive-letter case differences on Windows.

Happy to open a PR if useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions