1.0.6 • Published 6 years ago

with-temp-file v1.0.6

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

with-temp-file

Build Status Coverage Status

Call a function with a temporary file, and clean up when the function returns!

usage

Call withTempFile with a function that takes the writeStream and optionally your own temporary file name. It will be called. It can return a promise or call the callback which is the third argument of the function.

const withTempFile = require('with-temp-file')

async function main () {
    const result = await withTempFile((ws, filename) => {
        ws.write(fileContents())
        ws.end()

        return fs.readFileSync(filename) + ''
    })

    console.log(result)

    const result2 = await withTempFile((ws, filename, cb) => {
        ws.write(fileContents2())
        ws.end()

        cb()
    }, __dirname + '/.' + Math.random())

    console.log(result2)
}
1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago