google / google/jsonnet

Create output directories if they do not exist

Open
#195 6 comments 11 reactions 0 assignees View on GitHub
enhancement
Dominant language
Jsonnet
Stars
7.6k
Forks
475
PR merge metrics
No merged PRs in 30d

Description

I'd like to be able to invoke jsonnet like: `jsonnet -o foo/bar.json -e "{ foo: 'bar' }"` and have it create the `foo/` directory if it does not already exist. I'd like this to apply to multi-file output invocations as well. My use case is to have a file of the form:

```
{
'a.json': { /* snip */ },
'subdir/b.json': /* ... */,
'subdir/c.json': /* ... */,
}
```

but I'd like to be able to invoke `jsonnet -m` without having to know which subdirectories to create beforehand.

Currently, both invocations fail with the error:

```
$ jsonnet -o foo/bar.json -e "{ foo: 'bar' }"
Writing to output file: foo/bar.json: No such file or directory
$ jsonnet -m . foo.jsonnet
./a.json
./subdir/b.json
Opening output file: ./subdir/b.json: No such file or directory
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.