3.0.0 • Published 2 years ago

@m59/use-tmp-dir v3.0.0

Weekly downloads
1
License
ISC
Repository
github
Last release
2 years ago

@m59/use-tmp-dir

Takes a function and calls it with a path to a temporary directory. The temporary directory is removed after the function completes, or if the process exits meanwhile.

import { use_tmp_dir } from '@m59/use-tmp-dir'
import { access, writeFile } from 'node:fs/promises'
import { join as join_path } from 'node:path'

const removed_tmp_dir = await use_tmp_dir(
	async tmp_dir => {
		await writeFile(join_path(tmp_dir, 'some-file.txt'), 'some contents')
		return tmp_dir
	}
)

const error = await access(removed_tmp_dir)
	.catch(error => error)
error.code // => 'ENOENT'
3.0.0

2 years ago

2.0.0

3 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago