Spaces:
Running
Running
Download server/paths.ts from evalstate/mcp-webcam: direct link, hf CLI and curl.
- Browser
- Download file 1.4 kB
-
https://huggingface.co/spaces/evalstate/mcp-webcam/resolve/main/server/paths.ts
- Command line
-
hf download hf://spaces/evalstate/mcp-webcam/server/paths.ts
-
curl -L -o paths.ts https://huggingface.co/spaces/evalstate/mcp-webcam/resolve/main/server/paths.ts
1.4 kB
| import { existsSync, readFileSync } from 'node:fs'; | |
| import { dirname, resolve } from 'node:path'; | |
| import { fileURLToPath } from 'node:url'; | |
| const THIS_DIR = dirname(fileURLToPath(import.meta.url)); | |
| function resolveUiDir(): string { | |
| if (process.env.MCP_WEBCAM_UI_DIR) { | |
| return resolve(process.env.MCP_WEBCAM_UI_DIR); | |
| } | |
| // Built layout: dist/node/server/paths.js -> dist/ui | |
| const builtUiDir = resolve(THIS_DIR, '../../ui'); | |
| if (existsSync(builtUiDir)) { | |
| return builtUiDir; | |
| } | |
| // Source/dev layout: server/paths.ts -> dist/ui | |
| const devUiDir = resolve(THIS_DIR, '../dist/ui'); | |
| if (existsSync(devUiDir)) { | |
| return devUiDir; | |
| } | |
| return builtUiDir; | |
| } | |
| function resolvePackageVersion(): string { | |
| const candidates = [ | |
| resolve(THIS_DIR, '../../../package.json'), // dist/node/server/paths.js -> package.json | |
| resolve(THIS_DIR, '../package.json'), // server/paths.ts -> package.json | |
| ]; | |
| for (const candidate of candidates) { | |
| if (existsSync(candidate)) { | |
| try { | |
| const parsed = JSON.parse(readFileSync(candidate, 'utf8')) as { version?: unknown }; | |
| if (typeof parsed.version === 'string' && parsed.version.length > 0) { | |
| return parsed.version; | |
| } | |
| } catch { | |
| // ignore and try next candidate | |
| } | |
| } | |
| } | |
| return '0.3.0'; | |
| } | |
| export const UI_DIR = resolveUiDir(); | |
| export const PKG_VERSION = resolvePackageVersion(); | |