Skip to content

Commit

Permalink
Merge pull request #101 from hatappo/cljstyle-artifact-naming
Browse files Browse the repository at this point in the history
Fix to add cpu architecture suffix to artifact name of cljstyle
  • Loading branch information
DeLaGuardo authored Jan 9, 2024
2 parents 44fb9b5 + 2061fba commit 95652ba
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 19 deletions.
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

0 comments on commit 95652ba

Please sign in to comment.