-
Notifications
You must be signed in to change notification settings - Fork 0
Description
When creating temp files, right now you optionally pass it as first argument the file content, since the purpose of the module is to create temporary files the second argument can be skipped and the file would be created with a random filename, basically is good for most of the cases, since the actual generated filename and filepath can be retrieved on the temp file object, but in certain cases you might want to use a custom filename.
The current signature is:
function fileSync(content: any = "", options: FileWriteOptions = {})If a custom filename is needed the way is the following:
temp.fileSync({foo: "bar"}, { name: "config.json" })Since the FileWriteOptions are currently mostly related to the filename customization, the proposal is to implicitly assume that if the second function argument is a string, it will be the filename, such as this:
temp.fileSync({foo: "bar"}, "config.json")It's easier to read and less verbose, also the filename can be checked if is a relative or absolute file name/path and its sections (if any) used as the remaining FileWriteOptions keys.