blob: ad86a97fc176a851efeb57b26741db7bec9aeb5b (
plain) (
blame)
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
34
35
|
import { ConvertError } from "./errors";
import managers from "./managers";
import { Project } from "./types";
import { directoryInfo } from "./utils";
export default async function getWorkspaceDetails({
root,
}: {
root: string;
}): Promise<Project> {
const { exists, absolute: workspaceRoot } = directoryInfo({
directory: root,
});
if (!exists) {
throw new ConvertError(
`Could not find directory at ${workspaceRoot}. Ensure the directory exists.`,
{
type: "invalid_directory",
}
);
}
for (const { detect, read } of Object.values(managers)) {
if (await detect({ workspaceRoot })) {
return read({ workspaceRoot });
}
}
throw new ConvertError(
"Could not determine package manager. Add `packageManager` to `package.json` or ensure a lockfile is present.",
{
type: "package_manager-unable_to_detect",
}
);
}
|