raszi / node-tmp

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

fix #182 fileSync takes empty string postfix option #183

Closed gutte closed 5 years ago

gutte commented 5 years ago

{postfix :""} gives filename without file extension.

silkentrance commented 5 years ago

@gutte nice find. the same is true for the async file method. perhaps you want to fix it there, too?

silkentrance commented 5 years ago

@gutte some tests against this issue would be nice, too.

silkentrance commented 5 years ago

Looking at _generateTmpName(opts), this seems to be the original and desired behaviour, if the user decides to pass in an empty postfix, then the file shall have no '.tmp' extension, see at the very end of the _generateTmpName(opts) function, where the name is assembled from an array.

silkentrance commented 5 years ago

Okay, here was inverse logic in place. The issue correctly describes the wrong behaviour.

raszi commented 5 years ago

Good find, but we'll need to add tests for this.

gutte commented 5 years ago

Hey, yes sorry for the short pull request description. The issue description is clearer.

The behavior for fallback to the default postfix (.tmp) should now be the same for sync and async functions.

silkentrance commented 5 years ago

I am currently doing the tests for this, both for async/sync file and also for async/sync tmpName.