MCPcopy Index your code
hub / github.com/nodejs/node / mkdtempDisposableSync

Function mkdtempDisposableSync

lib/fs.js:3611–3631  ·  view source on GitHub ↗

* Synchronously creates a unique temporary directory. * The returned value is a disposable object which removes the * directory and its contents when disposed. * @param {string | Buffer | URL} prefix * @param {string | { encoding?: string; }} [options] * @returns {object} A disposable object wi

(prefix, options)

Source from the content-addressed store, hash-verified

3609 * @returns {object} A disposable object with a "path" property.
3610 */
3611function mkdtempDisposableSync(prefix, options) {
3612 options = getOptions(options);
3613
3614 prefix = getValidatedPath(prefix, 'prefix');
3615 warnOnNonPortableTemplate(prefix);
3616
3617 const path = binding.mkdtemp(prefix, options.encoding);
3618 // Stash the full path in case of process.chdir()
3619 const fullPath = pathModule.resolve(process.cwd(), path);
3620
3621 const remove = () => {
3622 binding.rmSync(fullPath, 0 /* maxRetries */, true /* recursive */, 100 /* retryDelay */);
3623 };
3624 return {
3625 path,
3626 remove,
3627 [SymbolDispose]() {
3628 remove();
3629 },
3630 };
3631}
3632
3633/**
3634 * Asynchronously copies `src` to `dest`. By

Callers

nothing calls this directly

Calls 4

mkdtempMethod · 0.80
getOptionsFunction · 0.50
resolveMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…