Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correctly remove file extension on types import path #742

Merged
merged 2 commits into from
Oct 16, 2023

Conversation

dpilch
Copy link
Member

@dpilch dpilch commented Oct 13, 2023

Description of changes

Correctly remove file extensions on types import path. See #741 for details.

Issue #, if available

Resolves: #741

Description of how you validated changes

  • Unit testing

Checklist

  • PR description included
  • yarn test passes
  • Tests are changed or added
  • Changes are tested using sample applications for all relevant platforms (iOS/android/flutter/Javascript) that use the feature added/modified

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@dpilch dpilch requested a review from a team as a code owner October 13, 2023 14:59
alharris-at
alharris-at previously approved these changes Oct 13, 2023
@@ -36,7 +36,7 @@ export class GraphQLStatementsFormatter {
this.lintOverrides = [];
this.headerComments = [];
this.typesPath = typesPath
? typesPath.replace(/.ts/i, '')
? typesPath.replace(/\.[^.]+$/, '') // remove file extensions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use Node's path module for this? path.parse(typesPath).ext will give you the extension to remove; .name will give the name exclusive of the extension, .dir + .name seems like what you want here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about this and thought the regex would be cleaner. But looking at it again path.parse would be more error resistant.

@dpilch dpilch merged commit f74aaa7 into main Oct 16, 2023
3 checks passed
@dpilch dpilch deleted the fix-file-ext-regex branch October 16, 2023 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Codegen path to types incorrect
3 participants