⚝
One Hat Cyber Team
⚝
Your IP:
172.22.0.1
Server IP:
151.80.20.34
Server:
Linux 794f04d97d5e 5.15.0-143-generic #153-Ubuntu SMP Fri Jun 13 19:10:45 UTC 2025 x86_64
Server Software:
Apache/2.4.62 (Debian)
PHP Version:
8.2.28
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
share
/
nodejs
/
@npmcli
/
fs
/
lib
/
View File Name :
with-temp-dir.js
const { join, sep } = require('path') const getOptions = require('./common/get-options.js') const { mkdir, mkdtemp, rm } = require('fs/promises') // create a temp directory, ensure its permissions match its parent, then call // the supplied function passing it the path to the directory. clean up after // the function finishes, whether it throws or not const withTempDir = async (root, fn, opts) => { const options = getOptions(opts, { copy: ['tmpPrefix'], }) // create the directory await mkdir(root, { recursive: true }) const target = await mkdtemp(join(`${root}${sep}`, options.tmpPrefix || '')) let err let result try { result = await fn(target) } catch (_err) { err = _err } try { await rm(target, { force: true, recursive: true }) } catch { // ignore errors } if (err) { throw err } return result } module.exports = withTempDir