java2typescript icon indicating copy to clipboard operation
java2typescript copied to clipboard

entry is not always absolute while "fromFile" contract expects so

Open aasselin-en opened this issue 1 year ago • 2 comments

Hello,

in the documentation of "fromFile" the "source" should always be an absolute path (so as to allow the startsWith to work), however it seems that in our conditions glob.sync will return a path relative to current working dir, even though the path specified in the configuration is absolute.

https://github.com/mike-lischke/java2typescript/blob/b0f2057cbddcd2723bfe6c59bc922a9ed23eb7e4/src/conversion/JavaToTypeScript.ts#L248

https://github.com/mike-lischke/java2typescript/blob/b0f2057cbddcd2723bfe6c59bc922a9ed23eb7e4/src/PackageSourceManager.ts#L39C8-L39C9

I modified porduced code that way to make the tool work:

const source = PackageSourceManager.fromFile(path.resolve(currentDir, entry), path.resolve(currentDir, target), root, this.configuration.sourceReplace);

Best regards Armel

aasselin-en avatar May 21 '24 12:05 aasselin-en

I see, thanks. If you like you could open a PR.

mike-lischke avatar May 21 '24 13:05 mike-lischke

I hoped that I'd be able to do it quickly, but I am super loaded these days with other tasks

aasselin-en avatar May 23 '24 07:05 aasselin-en