-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix windows executable name #41
Changes from 7 commits
1b1cf9d
8bd5b6e
3e9063e
900e8d0
0adc06c
1bf3311
aa1b316
89da6f6
5311814
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
if($args.count -ne 1) { | ||
Write-Host "This command requires 1 arg with the version to check" | ||
exit 1 | ||
} | ||
|
||
$result = pkl.exe --version | Select-String -Pattern $args[0] -Quiet | ||
|
||
if($result -eq "True") { | ||
exit 0 | ||
} else { | ||
exit 1 | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import os from 'node:os' | ||
|
||
enum Platform { | ||
Linux, | ||
MacOS, | ||
Windows | ||
} | ||
|
||
enum Architecture { | ||
arm64, | ||
x64 | ||
} | ||
|
||
type PlatformInfo = { | ||
plat: Platform | ||
arch: Architecture | ||
githubSourceAssetName: string | ||
targetFileName: string | ||
} | ||
|
||
export function determinePlatformInfo(): PlatformInfo { | ||
const plat = determineOS() | ||
const arch = determineArch() | ||
|
||
return { | ||
plat, | ||
arch, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't look like these two are used by the caller |
||
githubSourceAssetName: determineGithubAsset(plat, arch), | ||
targetFileName: determineTargetFileName(plat) | ||
} | ||
} | ||
|
||
function determineOS(): Platform { | ||
switch (os.platform()) { | ||
case 'linux': | ||
return Platform.Linux | ||
case 'darwin': | ||
return Platform.MacOS | ||
case 'win32': | ||
return Platform.Windows | ||
default: | ||
throw new Error('Unsupported platform') | ||
} | ||
} | ||
|
||
function determineArch(): Architecture { | ||
switch (os.arch()) { | ||
case 'arm64': | ||
return Architecture.arm64 | ||
case 'x64': | ||
return Architecture.x64 | ||
default: | ||
throw new Error('Unsupported architecture') | ||
} | ||
} | ||
|
||
function determineGithubAsset(plat: Platform, arch: Architecture): string { | ||
switch (plat) { | ||
case Platform.Linux: | ||
switch (arch) { | ||
case Architecture.arm64: | ||
return 'pkl-linux-aarch64' | ||
case Architecture.x64: | ||
return 'pkl-linux-amd64' | ||
default: | ||
throw new Error('Unsupported architecture') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this can happen here, right? Since |
||
} | ||
case Platform.MacOS: | ||
switch (arch) { | ||
case Architecture.arm64: | ||
return 'pkl-macos-aarch64' | ||
case Architecture.x64: | ||
return 'pkl-macos-amd64' | ||
default: | ||
throw new Error('Unsupported architecture') | ||
} | ||
case Platform.Windows: | ||
switch (arch) { | ||
case Architecture.arm64: | ||
throw new Error('Windows arm not yet supported') | ||
case Architecture.x64: | ||
return 'pkl-windows-amd64.exe' | ||
default: | ||
throw new Error('Unsupported architecture') | ||
} | ||
default: | ||
throw new Error('Unsupported platform') | ||
} | ||
} | ||
|
||
function determineTargetFileName(plat: Platform): string { | ||
switch (plat) { | ||
case Platform.Windows: | ||
return 'pkl.exe' | ||
default: | ||
return 'pkl' | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I generally prefer
as const
objects or arrays instead of enums - enums are one of the few TypeScript features which are transpiled into entirely different runtime code (whereas most TypeScript type-related syntax is simply erased).