1'use strict'; 2var isWindows = process.platform === 'win32'; 3var trailingSlashRe = isWindows ? /[^:]\\$/ : /.\/$/; 4 5// https://github.com/nodejs/node/blob/3e7a14381497a3b73dda68d05b5130563cdab420/lib/os.js#L25-L43 6module.exports = function () { 7 var path; 8 9 if (isWindows) { 10 path = process.env.TEMP || 11 process.env.TMP || 12 (process.env.SystemRoot || process.env.windir) + '\\temp'; 13 } else { 14 path = process.env.TMPDIR || 15 process.env.TMP || 16 process.env.TEMP || 17 '/tmp'; 18 } 19 20 if (trailingSlashRe.test(path)) { 21 path = path.slice(0, -1); 22 } 23 24 return path; 25}; 26