summaryrefslogtreecommitdiffhomepage
path: root/app/lib/tempdir.js
blob: e9f65cd03b075b4e6cbc6230740b36ac28cdfdbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// @flow

import path from 'path';

export function getSystemTemporaryDirectory() {
  switch(process.platform) {
  case 'win32': {
    const windowsPath = process.env.windir;
    if(windowsPath) {
      return path.join(windowsPath, 'Temp');
    } else {
      throw new Error('Missing windir in environment variables.');
    }
  }
  case 'darwin':
  case 'linux':
    return '/tmp';
  default:
    throw new Error(`Not implemented for ${process.platform}`);
  }
}