File size: 1,072 Bytes
cd8bd0a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
37
38
39
40
41
42
export function getRuntimePlatform(): string {
  return typeof process !== "undefined" && typeof process.platform === "string"
    ? process.platform
    : "unknown";
}

export function getRuntimeArch(): string {
  return typeof process !== "undefined" && typeof process.arch === "string"
    ? process.arch
    : "unknown";
}

export function getRuntimeNodeVersion(): string {
  return typeof process !== "undefined" && process.versions?.node
    ? process.versions.node
    : "unknown";
}

export function normalizeCloudCodePlatform(platform = getRuntimePlatform()): string {
  switch (platform) {
    case "win32":
      return "windows";
    case "darwin":
      return "macos";
    default:
      return platform || "unknown";
  }
}

export function normalizeCloudCodeArch(arch = getRuntimeArch()): string {
  switch (arch) {
    case "ia32":
      return "x86";
    default:
      return arch || "unknown";
  }
}

export function getCloudCodeNodeApiClientHeader(nodeVersion = getRuntimeNodeVersion()): string {
  return `gl-node/${nodeVersion.replace(/^v/, "")}`;
}