tempdir-transaction

1.0.1 • Public • Published

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
}

Readme

Keywords

none

Package Sidebar

Install

npm i tempdir-transaction

Weekly Downloads

0

Version

1.0.1

License

MIT

Last publish

Collaborators

  • str_t