stephenh / ts-poet

A code generator DSL for typescript
Apache License 2.0
100 stars 12 forks source link

Fix relative import handling in maybeRelativePath function #55

Closed lukealvoeiro closed 7 months ago

lukealvoeiro commented 7 months ago

This PR primarily focuses on improving the handling of relative imports in the src/Import.ts. It adds a condition to handle cases where the importing file is in a directory with the same name as the file it is importing from a directory above it.

// --- BEFORE
// file doing the importing: ./foo/bar
// file being imported: ./foo
// resulting import statement: ./

// --- AFTER
// file doing the importing: ./foo/bar
// file being imported: ./foo
// resulting import statement: ../foo

It also includes minor changes to the src/standalone-tests.ts and src/Import-tests.ts files to test the import functionality.

stephenh commented 7 months ago

Huh! That looks tricky! Thanks for the PR; I'll merge this and bump a release...

stephenh commented 7 months ago

@lukealvoeiro I just published this to npm as v6.7.0.