fix(cli): create output directory if it doesn't exist#1445
Open
lamine2000 wants to merge 1 commit into
Open
Conversation
Collaborator
|
Thanks @lamine2000 . There's a failing test here that needs resolving. Also this branch includes your other work. Please rebase against main so that this PR is nice and clean. Thank you! |
The compile and collections commands threw ENOENT when --output-path
pointed to a directory that hadn't been created yet. Add
mkdir({ recursive: true }) before writeFile in both handlers, matching
the pattern already used in the execute command's serialize-output.ts.
Fixes OpenFn#859
e34452a to
5686653
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #859. The
compileandcollections getcommands threwENOENTwhen--output-pathpointed to a directory that hadn't been created yet, forcing users to manuallymkdirbefore running the CLI.compile/handler.ts: addedawait mkdir(dirname(outputPath), { recursive: true })beforewriteFilecollections/handler.ts: same fix in thegetcommand's output branchThe
executecommand'sserialize-output.tsalready had this pattern — this PR brings the other two commands in line with it.Test plan
openfn compile job.js -o new/nested/dir/out.js— should createnew/nested/dir/and write the fileopenfn collections get myCollection myKey -o new/nested/dir/out.json— sameCloses #859