1 | import * as path from 'path';
|
2 | import * as mkdirp from 'mkdirp';
|
3 |
|
4 | export const isMac = process.platform === 'darwin';
|
5 | export const isLinux = process.platform === 'linux';
|
6 | export const isWindows = process.platform === 'win32';
|
7 |
|
8 |
|
9 | export let configDir: string;
|
10 | if (isWindows && process.env.LOCALAPPDATA) {
|
11 | configDir = path.join(process.env.LOCALAPPDATA, 'devcert', 'config');
|
12 | } else {
|
13 | let uid = process.getuid && process.getuid();
|
14 | let userHome = (isLinux && uid === 0) ? path.resolve('/usr/local/share') : require('os').homedir();
|
15 | configDir = path.join(userHome, '.config', 'devcert');
|
16 | }
|
17 | export const configPath: (...pathSegments: string[]) => string = path.join.bind(path, configDir);
|
18 |
|
19 | export const opensslConfTemplate = path.join(__dirname, '..', 'openssl.conf');
|
20 | export const opensslConfPath = configPath('openssl.conf');
|
21 | export const rootKeyPath = configPath('devcert-ca-root.key');
|
22 | export const rootCertPath = configPath('devcert-ca-root.crt');
|
23 | export const caCertsDir = configPath('certs');
|
24 |
|
25 | mkdirp.sync(configDir);
|
26 | mkdirp.sync(caCertsDir);
|