raszi / node-tmp

Temporary file and directory creator for node.js
MIT License
736 stars 92 forks source link

How to create a tmp file with extension #200

Closed ktalebian closed 4 years ago

ktalebian commented 4 years ago

How can I create a tmp file with an extension?

bartvanandel commented 4 years ago

There is an option called postfix. E.g., this will create a file named prefix-???-postfix.txt where ??? is some random string inserted by the library:

const txtFileObj = tmp.fileSync({
    prefix: `prefix-`,
    postfix: '-postfix.txt',
});
silkentrance commented 4 years ago

Thanks to @bartvanandel for answering the question.

See also the options https://github.com/raszi/node-tmp#options