summaryrefslogtreecommitdiffhomepage
path: root/app/lib/tempdir.js
blob: a3b4fa6d8959da23e34ac34183c1ef88c9ac2331 (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}`);
  }
}