raszi / node-tmp

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

fix #197: return sync callback when using the sync interface, otherwise return the async callback #220

Closed silkentrance closed 4 years ago

silkentrance commented 4 years ago

internally, we still use the synchronous remove functions on process exit.

silkentrance commented 4 years ago

file tests using name option fails in before hook on appveyor while it succeeds on both my local linux machine and travis.

need to investigate this further:

  1) tmp
       #file()
         when running inband standard tests
           with name
             "before all" hook: bound before for "should return a proper result":
     Error: EPERM: operation not permitted, open 'C:\Users\appveyor\AppData\Local\Temp\1\tmp-using-name'

file tests are run after dir tests. it seems as if the temporary directory created by the dir tests had not been removed, even though that the assertion for checking whether the directory does not exists will not fail during testing.

for now, putting a guard around the call to the sync cleanup callback in case that fileSync tests leave behind some remnants.

next: test this on a windows machine.

silkentrance commented 4 years ago

actually calling the sync cleanup callback during test seems to have done the trick. still wondering why rimraf fails on non existent files, though.

silkentrance commented 4 years ago

TODO: we might have a missing test here: sync file and dir operations must return the fully qualified path and not just the name that was either provided in the opts or that was generated by tmpName*.

then again, we have in assertions both assertExists and assertDoesNotExist.

so we need to investigate, better be sure than sorry.