feat: throw error if the platform is not linux

This commit is contained in:
Kengo TODA
2020-08-28 19:41:36 +08:00
parent 52b82a3e33
commit 0cc2e1f005
3 changed files with 22 additions and 3 deletions

View File

@@ -16,7 +16,7 @@ export async function runCommand(command: string): Promise<string> {
return output.trim()
}
export async function install(version: string): Promise<string> {
async function installOnLinux(version: string): Promise<string> {
const system = runCommand('uname -s')
const hardware = runCommand('uname -m')
const url = `https://github.com/docker/compose/releases/download/${version}/docker-compose-${await system}-${await hardware}`
@@ -24,3 +24,12 @@ export async function install(version: string): Promise<string> {
await exec(`chmod +x ${installerPath}`)
return installerPath
}
export async function install(version: string): Promise<string> {
switch (process.platform) {
case 'linux':
return installOnLinux(version)
default:
throw new Error(`Unsupported platform: ${process.platform}`)
}
}