(platform = process.platform)
| 57 | * ones. Most CLIs do this as in practice only GUI apps use the standard macOS directories. |
| 58 | */ |
| 59 | export function getEnvPaths(platform = process.platform): Paths { |
| 60 | const paths = envPaths("code-server", { suffix: "" }) |
| 61 | const append = (p: string): string => path.join(p, "code-server") |
| 62 | switch (platform) { |
| 63 | case "darwin": |
| 64 | return { |
| 65 | // envPaths uses native directories so force Darwin to use the XDG spec |
| 66 | // to align with other CLI tools. |
| 67 | data: xdgBasedir.data ? append(xdgBasedir.data) : paths.data, |
| 68 | config: xdgBasedir.config ? append(xdgBasedir.config) : paths.config, |
| 69 | // Fall back to temp if there is no runtime dir. |
| 70 | runtime: xdgBasedir.runtime ? append(xdgBasedir.runtime) : paths.temp, |
| 71 | } |
| 72 | case "win32": |
| 73 | return { |
| 74 | data: paths.data, |
| 75 | config: paths.config, |
| 76 | // Windows doesn't have a runtime dir. |
| 77 | runtime: paths.temp, |
| 78 | } |
| 79 | default: |
| 80 | return { |
| 81 | data: paths.data, |
| 82 | config: paths.config, |
| 83 | // Fall back to temp if there is no runtime dir. |
| 84 | runtime: xdgBasedir.runtime ? append(xdgBasedir.runtime) : paths.temp, |
| 85 | } |
| 86 | } |
| 87 | } |
| 88 | |
| 89 | export const generateCertificate = async (hostname: string): Promise<{ cert: string; certKey: string }> => { |
| 90 | const certPath = path.join(paths.data, `${hostname.replace(/\./g, "_")}.crt`) |
no test coverage detected