Download core/src/node/helper/path.ts from oldg591/jannn: direct link, hf CLI and curl.
- Browser
- Download file 820 Bytes
-
https://huggingface.co/spaces/oldg591/jannn/resolve/main/core/src/node/helper/path.ts
- Command line
-
hf download hf://spaces/oldg591/jannn/core/src/node/helper/path.ts
-
curl -L -o path.ts https://huggingface.co/spaces/oldg591/jannn/resolve/main/core/src/node/helper/path.ts
820 Bytes
| import { join } from 'path' | |
| /** | |
| * Normalize file path | |
| * Remove all file protocol prefix | |
| * @param path | |
| * @returns | |
| */ | |
| export function normalizeFilePath(path: string): string { | |
| return path.replace(/^(file:[\\/]+)([^:\s]+)$/, '$2') | |
| } | |
| export async function appResourcePath(): Promise<string> { | |
| let electron: any = undefined | |
| try { | |
| const moduleName = 'electron' | |
| electron = await import(moduleName) | |
| } catch (err) { | |
| console.error('Electron is not available') | |
| } | |
| // electron | |
| if (electron && electron.protocol) { | |
| let appPath = join(electron.app.getAppPath(), '..', 'app.asar.unpacked') | |
| if (!electron.app.isPackaged) { | |
| // for development mode | |
| appPath = join(electron.app.getAppPath()) | |
| } | |
| return appPath | |
| } | |
| // server | |
| return join(global.core.appPath(), '../../..') | |
| } | |