Spaces:
Paused
Paused
Download src/lib/paths.ts from imseldrith/copilot-api: direct link, hf CLI and curl.
- Browser
- Download file 646 Bytes
-
https://huggingface.co/spaces/imseldrith/copilot-api/resolve/main/src/lib/paths.ts
- Command line
-
hf download hf://spaces/imseldrith/copilot-api/src/lib/paths.ts
-
curl -L -o paths.ts https://huggingface.co/spaces/imseldrith/copilot-api/resolve/main/src/lib/paths.ts
646 Bytes
| import fs from "node:fs/promises" | |
| import os from "node:os" | |
| import path from "node:path" | |
| const APP_DIR = path.join(os.homedir(), ".local", "share", "copilot-api") | |
| const GITHUB_TOKEN_PATH = path.join(APP_DIR, "github_token") | |
| export const PATHS = { | |
| APP_DIR, | |
| GITHUB_TOKEN_PATH, | |
| } | |
| export async function ensurePaths(): Promise<void> { | |
| await fs.mkdir(PATHS.APP_DIR, { recursive: true }) | |
| await ensureFile(PATHS.GITHUB_TOKEN_PATH) | |
| } | |
| async function ensureFile(filePath: string): Promise<void> { | |
| try { | |
| await fs.access(filePath, fs.constants.W_OK) | |
| } catch { | |
| await fs.writeFile(filePath, "") | |
| await fs.chmod(filePath, 0o600) | |
| } | |
| } | |