Skip to content
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 to add cpu architecture suffix to artifact name of cljstyle #101

Merged
merged 3 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions __tests__/cljstyle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ describe('cljstyle tests', () => {
describe('getArtifactName', () => {
test.each`
platform | artifact
${'darwin'} | ${`cljstyle_1.2.3_macos.zip`}
${'linux'} | ${`cljstyle_1.2.3_linux.zip`}
${'foobar'} | ${`cljstyle_1.2.3_linux.zip`}
${'darwin'} | ${`cljstyle_1.2.3_macos_amd64.zip`}
${'linux'} | ${`cljstyle_1.2.3_linux_amd64.zip`}
${'foobar'} | ${`cljstyle_1.2.3_linux_amd64.zip`}
`('$platform -> $artifact', ({platform, artifact}) => {
os.platform.mockReturnValueOnce(platform as never)
expect(cljstyle.getArtifactName('1.2.3')).toBe(artifact)
Expand All @@ -76,14 +76,17 @@ describe('cljstyle tests', () => {

describe('getArtifactUrl', () => {
test.each`
platform | artifact
${'darwin'} | ${`cljstyle_1.2.3_macos.zip`}
${'linux'} | ${`cljstyle_1.2.3_linux.zip`}
${'foobar'} | ${`cljstyle_1.2.3_linux.zip`}
`('$platform -> $artifact', ({platform, artifact}) => {
platform | version | artifact
${'darwin'} | ${'1.2.3'} | ${`cljstyle_1.2.3_macos_amd64.zip`}
${'linux'} | ${'1.2.3'} | ${`cljstyle_1.2.3_linux_amd64.zip`}
${'foobar'} | ${'1.2.3'} | ${`cljstyle_1.2.3_linux_amd64.zip`}
${'darwin'} | ${'0.15.0'} | ${`cljstyle_0.15.0_macos.zip`}
${'linux'} | ${'0.15.0'} | ${`cljstyle_0.15.0_linux.zip`}
${'foobar'} | ${'0.15.0'} | ${`cljstyle_0.15.0_linux.zip`}
`('$platform -> $artifact', ({platform, version, artifact}) => {
os.platform.mockReturnValueOnce(platform as never)
expect(cljstyle.getArtifactUrl('1.2.3')).toBe(
`https://github.com/greglook/cljstyle/releases/download/1.2.3/${artifact}`
expect(cljstyle.getArtifactUrl(version)).toBe(
`https://github.com/greglook/cljstyle/releases/download/${version}/${artifact}`
)
})
})
Expand Down Expand Up @@ -116,7 +119,7 @@ describe('cljstyle tests', () => {

expect(tc.find).toHaveBeenCalledWith('cljstyle', '1.2.3')
expect(tc.downloadTool).toHaveBeenCalledWith(
'https://github.com/greglook/cljstyle/releases/download/1.2.3/cljstyle_1.2.3_linux.zip',
'https://github.com/greglook/cljstyle/releases/download/1.2.3/cljstyle_1.2.3_linux_amd64.zip',
undefined,
'token 123'
)
Expand All @@ -140,7 +143,7 @@ describe('cljstyle tests', () => {
)
expect(tc.find).toHaveBeenCalledWith('cljstyle', '9.9.9')
expect(tc.downloadTool).toHaveBeenCalledWith(
'https://github.com/greglook/cljstyle/releases/download/9.9.9/cljstyle_9.9.9_linux.zip',
'https://github.com/greglook/cljstyle/releases/download/9.9.9/cljstyle_9.9.9_linux_amd64.zip',
undefined,
'token 123'
)
Expand Down
6 changes: 4 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -804,12 +804,14 @@ function getLatestCljstyle(githubAuth) {
}
exports.getLatestCljstyle = getLatestCljstyle;
function getArtifactName(version) {
const [major, minor] = version.split('.').map(n => parseInt(n));
const archiSuffix = major > 0 || minor > 15 ? '_amd64' : '';
const platform = os.platform();
switch (platform) {
case 'darwin':
return `cljstyle_${version}_macos.zip`;
return `cljstyle_${version}_macos${archiSuffix}.zip`;
default:
return `cljstyle_${version}_linux.zip`;
return `cljstyle_${version}_linux${archiSuffix}.zip`;
}
}
exports.getArtifactName = getArtifactName;
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

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

6 changes: 4 additions & 2 deletions src/cljstyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ export async function getLatestCljstyle(githubAuth?: string): Promise<string> {
}

export function getArtifactName(version: string): string {
const [major, minor] = version.split('.').map(n => parseInt(n))
const archiSuffix = major > 0 || minor > 15 ? '_amd64' : ''
const platform = os.platform()
switch (platform) {
case 'darwin':
return `cljstyle_${version}_macos.zip`
return `cljstyle_${version}_macos${archiSuffix}.zip`
default:
return `cljstyle_${version}_linux.zip`
return `cljstyle_${version}_linux${archiSuffix}.zip`
}
}

Expand Down