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