Package Exports
- with-local-tmp-dir
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (with-local-tmp-dir) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
with-local-tmp-dir
Creates a temporary folder inside CWD and passes the path to a function. Afterwards, the folder is removed. Especially useful for testing with real files.
Installation
npm install --save with-local-tmp-dirUsage
const withLocalTmpDir = require('with-local-tmp-dir')
withLocalTmpDir(path => {
console.log(path)
//> /Users/max/project/tmp-18815DudQxmdn03Rz
})
// Now the folder does not exist anymore
// Also works with async functions =)
withLocalTmpDir(async path => await ...)
// The folder is removed even if an exception is thrown
withLocalTmpDir(async path => throw new Error('File could not be found'))License
MIT © Sebastian Landwehr