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

Add support for nested directories #175

Merged
merged 5 commits into from
Jun 9, 2021
Merged

Conversation

FrigoEU
Copy link
Contributor

@FrigoEU FrigoEU commented Jun 3, 2021

Small PR to allow finding and generating definitions and index files for .sql files in nested directories!

src/codegen.ts Outdated
modules: TsModule[]
): string {
const nestedDirsStr = nestedDirs
.map((dir) => `export * from '${path.relative(dirPath, dir.dirPath)}';`)
Copy link
Owner

Choose a reason for hiding this comment

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

I'm not sure it's the best way to "flatten" the directory structure by exporting like this. Maybe export * as subdir from './subdir' would be better? The you could import * as sql from './sql' and use sql.subdir.func() for using the queries in the subdirectory.

And BTW, even as is the code should be export * from './${path... because otherwise you're trying to import a package from node_modules :)

@akheron
Copy link
Owner

akheron commented Jun 4, 2021

It would also be cool if you modified the cli tests to also include the subdirectory functionality. Maybe just move one of the sql files under tests/cli/sqls to a subdirectory, and adjust check.ts.template to work with the new directory layout. That should be enough!

Nice work in any case, and I think this would be a good addition!

@FrigoEU
Copy link
Contributor Author

FrigoEU commented Jun 9, 2021

That should do it, thanks for the feedback!

@akheron akheron added the feature label Jun 9, 2021
@akheron akheron merged commit 4381421 into akheron:main Jun 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants