Skip to content

Commit 95652ba

Browse files
authored
Merge pull request #101 from hatappo/cljstyle-artifact-naming
Fix to add cpu architecture suffix to artifact name of cljstyle
2 parents 44fb9b5 + 2061fba commit 95652ba

File tree

5 files changed

+26
-19
lines changed

5 files changed

+26
-19
lines changed

__tests__/cljstyle.test.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ describe('cljstyle tests', () => {
6565
describe('getArtifactName', () => {
6666
test.each`
6767
platform | artifact
68-
${'darwin'} | ${`cljstyle_1.2.3_macos.zip`}
69-
${'linux'} | ${`cljstyle_1.2.3_linux.zip`}
70-
${'foobar'} | ${`cljstyle_1.2.3_linux.zip`}
68+
${'darwin'} | ${`cljstyle_1.2.3_macos_amd64.zip`}
69+
${'linux'} | ${`cljstyle_1.2.3_linux_amd64.zip`}
70+
${'foobar'} | ${`cljstyle_1.2.3_linux_amd64.zip`}
7171
`('$platform -> $artifact', ({platform, artifact}) => {
7272
os.platform.mockReturnValueOnce(platform as never)
7373
expect(cljstyle.getArtifactName('1.2.3')).toBe(artifact)
@@ -76,14 +76,17 @@ describe('cljstyle tests', () => {
7676

7777
describe('getArtifactUrl', () => {
7878
test.each`
79-
platform | artifact
80-
${'darwin'} | ${`cljstyle_1.2.3_macos.zip`}
81-
${'linux'} | ${`cljstyle_1.2.3_linux.zip`}
82-
${'foobar'} | ${`cljstyle_1.2.3_linux.zip`}
83-
`('$platform -> $artifact', ({platform, artifact}) => {
79+
platform | version | artifact
80+
${'darwin'} | ${'1.2.3'} | ${`cljstyle_1.2.3_macos_amd64.zip`}
81+
${'linux'} | ${'1.2.3'} | ${`cljstyle_1.2.3_linux_amd64.zip`}
82+
${'foobar'} | ${'1.2.3'} | ${`cljstyle_1.2.3_linux_amd64.zip`}
83+
${'darwin'} | ${'0.15.0'} | ${`cljstyle_0.15.0_macos.zip`}
84+
${'linux'} | ${'0.15.0'} | ${`cljstyle_0.15.0_linux.zip`}
85+
${'foobar'} | ${'0.15.0'} | ${`cljstyle_0.15.0_linux.zip`}
86+
`('$platform -> $artifact', ({platform, version, artifact}) => {
8487
os.platform.mockReturnValueOnce(platform as never)
85-
expect(cljstyle.getArtifactUrl('1.2.3')).toBe(
86-
`https://github.com/greglook/cljstyle/releases/download/1.2.3/${artifact}`
88+
expect(cljstyle.getArtifactUrl(version)).toBe(
89+
`https://github.com/greglook/cljstyle/releases/download/${version}/${artifact}`
8790
)
8891
})
8992
})
@@ -116,7 +119,7 @@ describe('cljstyle tests', () => {
116119

117120
expect(tc.find).toHaveBeenCalledWith('cljstyle', '1.2.3')
118121
expect(tc.downloadTool).toHaveBeenCalledWith(
119-
'https://github.com/greglook/cljstyle/releases/download/1.2.3/cljstyle_1.2.3_linux.zip',
122+
'https://github.com/greglook/cljstyle/releases/download/1.2.3/cljstyle_1.2.3_linux_amd64.zip',
120123
undefined,
121124
'token 123'
122125
)
@@ -140,7 +143,7 @@ describe('cljstyle tests', () => {
140143
)
141144
expect(tc.find).toHaveBeenCalledWith('cljstyle', '9.9.9')
142145
expect(tc.downloadTool).toHaveBeenCalledWith(
143-
'https://github.com/greglook/cljstyle/releases/download/9.9.9/cljstyle_9.9.9_linux.zip',
146+
'https://github.com/greglook/cljstyle/releases/download/9.9.9/cljstyle_9.9.9_linux_amd64.zip',
144147
undefined,
145148
'token 123'
146149
)

dist/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -804,12 +804,14 @@ function getLatestCljstyle(githubAuth) {
804804
}
805805
exports.getLatestCljstyle = getLatestCljstyle;
806806
function getArtifactName(version) {
807+
const [major, minor] = version.split('.').map(n => parseInt(n));
808+
const archiSuffix = major > 0 || minor > 15 ? '_amd64' : '';
807809
const platform = os.platform();
808810
switch (platform) {
809811
case 'darwin':
810-
return `cljstyle_${version}_macos.zip`;
812+
return `cljstyle_${version}_macos${archiSuffix}.zip`;
811813
default:
812-
return `cljstyle_${version}_linux.zip`;
814+
return `cljstyle_${version}_linux${archiSuffix}.zip`;
813815
}
814816
}
815817
exports.getArtifactName = getArtifactName;

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cljstyle.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@ export async function getLatestCljstyle(githubAuth?: string): Promise<string> {
2525
}
2626

2727
export function getArtifactName(version: string): string {
28+
const [major, minor] = version.split('.').map(n => parseInt(n))
29+
const archiSuffix = major > 0 || minor > 15 ? '_amd64' : ''
2830
const platform = os.platform()
2931
switch (platform) {
3032
case 'darwin':
31-
return `cljstyle_${version}_macos.zip`
33+
return `cljstyle_${version}_macos${archiSuffix}.zip`
3234
default:
33-
return `cljstyle_${version}_linux.zip`
35+
return `cljstyle_${version}_linux${archiSuffix}.zip`
3436
}
3537
}
3638

0 commit comments

Comments
 (0)