1.0.1 • Published 8 years ago

tempdir-transaction v1.0.1

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

tempdir-transaction

npm install tempdir-transaction

Requires Promises to be in global scope

const tdtrans = require('tempdir-transaction')

async function () {
    // Given function is awaited with Promise.resolve
    const a = await tdtrans(async (tempdir) => {
        console.log(tempdir) // /tmp/912lfewjoifje-fweio
        fs.writeFileSync(path.join(tempdir, 'foo'), 'bar')
        return '123'
    })
    // Directory /tmp/912lfewjoifje-fweio has been removed at this point
    console.log(a) // 123
}