foundry
foundry copied to clipboard
feat: directory creation in scripts
Component
Other (please describe)
Describe the feature you would like
I found an issue when writing to a file using vm.writeFile() where the script breaks if the file is being written into a directory that does not yet exist. vm.writeFile() is only able to write to existing directories, and I have not seen functionality to create a directory directly from a script. This would be helpful, for example, if I want to write some of the output from script/Deploy.s.sol into my own script/output/{chainName}/Deploy.json file after broadcasting instead of needing to work with the whole Broadcast.json.
Since I'm working with the script on multiple chains, I don't always have the {chainName} directory created, and this feature would be much appreciated.
Additional context
No response
Is the feature request here to have vm.writeFile automatically create the directory if it doesn't exist, or to add a vm.mkdir cheat to create directories? Both seem reasonable to me, though just updating writeLine seems sufficient and would be my preference—it keeps the cheat interface smaller/simpler and accomplishes the same goal
The request would be the former - that vm.writeFile would automatically create the directory. vm.mkdir would be a nice to have but in terms of development process vm.writeFile should do all the lifting IMO
anybody working on this? would be a killer feature to have.
Update: Since #4803 vm.createDir(string,bool) now exists with bool indicating whether the missing directories should be created recursively.
Is this still proposed feature still desired? I think the existing vm.createDir should suffice in most cases.
Thanks for the ping @zerosnacks. This issue is now resolved.