Copy a file or directory to OS temporary dir with a random name. With option to remove it.
NodeJS v4.0 or greater.
yarn add tmpz --dev
npm install tmpz --save-dev
const tmpz = require('tmpz')
try {
const dest = tmpz.copy('./my_directory')
console.log(dest)
// > /tmp/393a6d0851bb6c10214f92bbaa9c833d
// Removing our temp dir in 7 seconds...
setTimeout(() => tmpz.remove(dest), 7000)
} catch (err) {
console.error(err)
}
MIT license
© 2017 José Luis Quintana