tmpDirSync
Less than 1 minute
function tmpDirSync(options): TmpDirSyncHelper
Creates a temporary directory synchronously.
Parameters
Parameter | Type | Description |
---|---|---|
| Options for creating the temporary directory. |
Returns
A TmpDirSyncHelper.
Example
// Create a temporary directory with a custom prefix
const dir = tmpDirSync({ prefix: 'my-temp-dir' });
console.log('Temporary directory created at:', dir.root);
// Check if a file exists in the temporary directory
const exists = dir.exists('some-file.txt');
console.log('File exists:', exists);
// Clean up the temporary directory
dir.clean();
console.log('Temporary directory cleaned:', dir.cleaned());
// Track the temporary directory for automatic cleanup on process exit
dir.track();
console.log('Temporary directory tracked:', dir.tracked());
// Untrack the temporary directory
dir.untrack();
console.log('Temporary directory untracked:', dir.tracked());