Download packages/cli/src/utils/package.ts from Jimmi42/openCLI: direct link, hf CLI and curl.
- Browser
- Download file 804 Bytes
-
https://huggingface.co/Jimmi42/openCLI/resolve/main/packages/cli/src/utils/package.ts
- Command line
-
hf download hf://Jimmi42/openCLI/packages/cli/src/utils/package.ts
-
curl -L -o package.ts https://huggingface.co/Jimmi42/openCLI/resolve/main/packages/cli/src/utils/package.ts
804 Bytes
| /** | |
| * @license | |
| * Copyright 2025 Google LLC | |
| * SPDX-License-Identifier: Apache-2.0 | |
| */ | |
| import { | |
| readPackageUp, | |
| type PackageJson as BasePackageJson, | |
| } from 'read-package-up'; | |
| import { fileURLToPath } from 'url'; | |
| import path from 'path'; | |
| export type PackageJson = BasePackageJson & { | |
| config?: { | |
| sandboxImageUri?: string; | |
| }; | |
| }; | |
| const __filename = fileURLToPath(import.meta.url); | |
| const __dirname = path.dirname(__filename); | |
| let packageJson: PackageJson | undefined; | |
| export async function getPackageJson(): Promise<PackageJson | undefined> { | |
| if (packageJson) { | |
| return packageJson; | |
| } | |
| const result = await readPackageUp({ cwd: __dirname }); | |
| if (!result) { | |
| // TODO: Maybe bubble this up as an error. | |
| return; | |
| } | |
| packageJson = result.packageJson; | |
| return packageJson; | |
| } | |