java2typescript icon indicating copy to clipboard operation
java2typescript copied to clipboard

Does not work correctly on Windows

Open jamiegluk opened this issue 1 year ago • 3 comments

This package uses hardcoded forward slashes with plain string matching, mixed with path.resolve uses that will return backslashes on Windows, thus imports do not resolve correctly.

It works correctly if ran via WSL on Windows.

Recommend adding this to the README?

jamiegluk avatar Dec 06 '24 00:12 jamiegluk

Windows can cope with forward slashes. The only place where that doesn't work is in a terminal, because forward slashes are used a terminal command parameters.

And even a mix style (foward and back slash) shouldn't cause problems. What exactly are you seeing?

mike-lischke avatar Dec 06 '24 08:12 mike-lischke

If I had to guess, it's this issue that I'm seeing as well.

public static fromFile = (source: string, target: string, packageRoot: string,
        replacements?: Map<RegExp, string>): PackageSource => {
        // Construct a package name for lookup from the given paths.
        if (!source.startsWith(packageRoot)) {
            throw new Error("The full path must specify a file within the given package root.");
        }

The source string and package root string might not have consistent slash direction on windows, so the startsWith check always fails for me. Haven't been able to verify, but that's what I'm suspicious of right now.

Josh-V-PAL avatar Dec 09 '24 15:12 Josh-V-PAL

Oh, ok, that needs investigation, but I recommend to use forward slashes always.

mike-lischke avatar Dec 09 '24 16:12 mike-lischke