-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Expand file tree
/
Copy pathruntime-layout.mjs
More file actions
36 lines (32 loc) · 1.39 KB
/
Copy pathruntime-layout.mjs
File metadata and controls
36 lines (32 loc) · 1.39 KB
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
36
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------------------------------------------*/
import { realpathSync, statSync } from "node:fs";
import { join, resolve } from "node:path";
const RUNTIME_LAYOUT_MARKER = "script/sea-build.ts";
export function findRuntimeRoot(sdkRoot) {
const runtimeRoot = resolve(sdkRoot, "../..");
try {
if (
realpathSync(sdkRoot) !== realpathSync(join(runtimeRoot, "src/sdk")) ||
!statSync(join(runtimeRoot, RUNTIME_LAYOUT_MARKER)).isFile()
) {
return undefined;
}
return runtimeRoot;
} catch {
return undefined;
}
}
export function getRuntimeCliPaths(runtimeRoot, environment = process.env) {
const target = environment.COPILOT_RUNTIME_TARGET ?? `${process.platform}-${process.arch}`;
const wrapperName = process.platform === "win32" ? "copilot-runtime.exe" : "copilot-runtime";
return {
cliPath:
environment.COPILOT_CLI_PATH ??
(runtimeRoot ? join(runtimeRoot, "dist-cli", "prebuilds", target, wrapperName) : undefined),
legacyCliPath:
environment.COPILOT_LEGACY_CLI_PATH ??
(runtimeRoot ? join(runtimeRoot, "dist-cli", "app.js") : undefined),
};
}