uTools-quickcommand/plugin/lib/getQuickcommandTempFile.js
2024-12-28 16:35:56 +08:00

13 lines
433 B
JavaScript

const fs = require("fs");
const path = require("path");
const os = require("os");
const getQuickcommandTempFile = (ext, name, dir = "quickcommandTempDir") => {
if (!name) name = new Date().getTime() + (Math.random() * 10 ** 6).toFixed();
let tempDir = path.join(os.tmpdir(), dir);
if (!fs.existsSync(tempDir)) fs.mkdirSync(tempDir);
return path.join(tempDir, `${name}.${ext}`);
};
module.exports = getQuickcommandTempFile;