Skip to content

Commit

Permalink
Moved to one line CLI Argument
Browse files Browse the repository at this point in the history
  • Loading branch information
AS1100K committed Oct 13, 2024
1 parent 1e7a0d5 commit 9d0e211
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 62 deletions.
39 changes: 12 additions & 27 deletions __tests__/toolchain_install.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,11 @@ describe('install_toolchain', () => {
'rustup-init.exe'
)

expect(mockedExec).toHaveBeenCalledWith('./rustup-init.exe', [
'-v',
'--default-toolchain',
'stable',
'--profile',
'minimal',
'-y'
])

expect(mockedExec).toHaveBeenCalledWith('rm', ['rustup-init.exe'])
expect(mockedExec).toHaveBeenCalledWith(
'./rustup-init.exe -v --default-toolchain stable --profile minimal -y'
)

expect(mockedExec).toHaveBeenCalledWith('rm rustup-init.exe')
})

test('should install Rust on Windows ia32', async () => {
Expand All @@ -70,16 +65,11 @@ describe('install_toolchain', () => {
'rustup-init.exe'
)

expect(mockedExec).toHaveBeenCalledWith('./rustup-init.exe', [
'-v',
'--default-toolchain',
'stable',
'--profile',
'minimal',
'-y'
])
expect(mockedExec).toHaveBeenCalledWith(
'./rustup-init.exe -v --default-toolchain stable --profile minimal -y'
)

expect(mockedExec).toHaveBeenCalledWith('rm', ['rustup-init.exe'])
expect(mockedExec).toHaveBeenCalledWith('rm rustup-init.exe')
})

test('should throw an error for unsupported architecture on Windows', async () => {
Expand All @@ -100,14 +90,9 @@ describe('install_toolchain', () => {
await install_toolchain(properties, platform)

expect(mockedDownloadFile).not.toHaveBeenCalled()
expect(mockedExec).toHaveBeenCalledWith('curl', [
'--proto https --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -v',
'--default-toolchain',
'stable',
'--profile',
'minimal',
'-y'
])
expect(mockedExec).toHaveBeenCalledWith(
'curl --proto https --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -v --default-toolchain stable --profile minimal -y'
)
})

test('should handle errors thrown by download_rust', async () => {
Expand Down
20 changes: 3 additions & 17 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

24 changes: 7 additions & 17 deletions src/toolchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,27 +58,17 @@ async function download_rust(
}

// install rust via installer
await exec.exec('./rustup-init.exe', [
'-v',
'--default-toolchain',
properties.rust_toolchain,
'--profile',
properties.profile,
'-y'
])
await exec.exec(
`./rustup-init.exe -v --default-toolchain ${properties.rust_toolchain} --profile ${properties.profile} -y`
)

// uninstall the installer
await exec.exec('rm', ['rustup-init.exe'])
await exec.exec('rm rustup-init.exe')
} else {
// Install installer via direct script and download rust
await exec.exec('curl', [
'--proto https --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -v',
'--default-toolchain',
properties.rust_toolchain,
'--profile',
properties.profile,
'-y'
])
await exec.exec(
`curl --proto https --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -v --default-toolchain ${properties.rust_toolchain} --profile ${properties.profile} -y`
)
}
} catch (error) {
if (error instanceof Error) throw error
Expand Down

0 comments on commit 9d0e211

Please sign in to comment.