all files / modules/utils/ makeTemporaryPath.js

40% Statements 4/10
0% Branches 0/2
0% Functions 0/1
40% Lines 4/10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16                        
const path = require("path");
const TMP_DIR = require("os").tmpDir();
 
function makeTemporaryPath(prefix) {
    prefix = prefix || "";
 
    const random = (Math.random() * 0x100000000 + 1).toString(36);
    const now = new Date();
    const date = now.getYear().toString() + now.getMonth() + now.getDate();
    const name = [prefix, date, "-", process.pid, "-", random].join("");
 
    return path.join(TMP_DIR, name);
}
 
module.exports = makeTemporaryPath;