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

Create directories recursively if they don't exist #357

Open
GauBen opened this issue Sep 24, 2024 · 2 comments · May be fixed by #364
Open

Create directories recursively if they don't exist #357

GauBen opened this issue Sep 24, 2024 · 2 comments · May be fixed by #364

Comments

@GauBen
Copy link

GauBen commented Sep 24, 2024

Hey!

I'm generating the introspection types in a directory that is git-ignored, and graphqlsp does not create this directory automatically if not found

What do you think about adding something roughly like this?

if (output.endsWith('.ts')) {
  await mkdir(path.dirname(output), { recursive: true });
}

(with proper error handling of course)

Ref:

let output = tadaOutputLocation;
if (await statFile(output, stat => stat.isDirectory())) {
output = path.join(output, 'introspection.d.ts');
} else if (
!(await statFile(path.dirname(output), stat => stat.isDirectory()))
) {
logger(`Output file is not inside a directory @ ${output}`);
return;
}

I'd be happy to contribute a pull request if this change is accepted

@kitten
Copy link
Member

kitten commented Sep 24, 2024

I've got a corresponding fix up here at: 0no-co/gql.tada#401
I'm not sure if we want to share this code actually, but we could

@GauBen
Copy link
Author

GauBen commented Sep 24, 2024

Thanks for being so reactive!

@JoviDeCroock JoviDeCroock linked a pull request Oct 5, 2024 that will close this issue
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 a pull request may close this issue.

2 participants