-
Notifications
You must be signed in to change notification settings - Fork 10
/
cargo.ts
33 lines (28 loc) · 864 Bytes
/
cargo.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
import { $, PathRef } from "./deps.ts";
export interface CargoMetadata {
packages: CargoPackageMetadata[];
/** Identifiers in the `packages` array of the workspace members. */
"workspace_members": string[];
/** The absolute workspace root directory path. */
"workspace_root": string;
}
export interface CargoPackageMetadata {
id: string;
name: string;
version: string;
dependencies: CargoDependencyMetadata[];
/** Path to Cargo.toml */
"manifest_path": string;
}
export interface CargoDependencyMetadata {
name: string;
/** Version requrement (ex. ^0.1.0) */
req: string;
kind: "dev" | null;
}
export function getCargoMetadata(directory: PathRef | string) {
return $`cargo metadata --format-version 1`
.cwd(directory)
.json<CargoMetadata>();
}