-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: split out into multiple files
- Loading branch information
1 parent
8bb0271
commit c6e9637
Showing
4 changed files
with
318 additions
and
236 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import * as path from 'path'; | ||
import * as mkdirp from 'mkdirp'; | ||
|
||
export const isMac = process.platform === 'darwin'; | ||
export const isLinux = process.platform === 'linux'; | ||
export const isWindows = process.platform === 'win32'; | ||
|
||
// use %LOCALAPPDATA%/devcert on Windows otherwise use ~/.config/devcert | ||
export let configDir: string; | ||
if (isWindows && process.env.LOCALAPPDATA) { | ||
configDir = path.join(process.env.LOCALAPPDATA, 'devcert', 'config'); | ||
} else { | ||
let uid = process.getuid && process.getuid(); | ||
let userHome = (isLinux && uid === 0) ? path.resolve('/usr/local/share') : require('os').homedir(); | ||
configDir = path.join(userHome, '.config', 'devcert'); | ||
} | ||
export const configPath: (...pathSegments: string[]) => string = path.join.bind(path, configDir); | ||
|
||
export const opensslConfTemplate = path.join(__dirname, '..', 'openssl.conf'); | ||
export const opensslConfPath = configPath('openssl.conf'); | ||
export const rootKeyPath = configPath('devcert-ca-root.key'); | ||
export const rootCertPath = configPath('devcert-ca-root.crt'); | ||
export const caCertsDir = configPath('certs'); | ||
|
||
mkdirp.sync(configDir); | ||
mkdirp.sync(caCertsDir); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.