stonev5-utils
Version:
all my utils here
12 lines • 471 B
JavaScript
export function tempFile(content, prefix = 'temp-', suffix = '.txt') {
const fs = require('fs');
const os = require('os');
const path = require('path');
// Get the system's temporary directory
const tempDir = os.tmpdir();
const tempFilePath = path.join(tempDir, prefix + Math.random().toString(36).substring(2) + suffix);
if (content)
fs.writeFileSync(tempFilePath, content);
return tempFilePath;
}
//# sourceMappingURL=file.js.map