Skip to content

Create directories recursively if they don't exist #357

Open
@GauBen

Description

@GauBen

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions