Skip to content

Commit f3cf8af

Browse files
authored
Merge pull request #5 from qt-creator/releases/v1.3
Add path-with-slashes output
2 parents 753a974 + f9d4ad5 commit f3cf8af

File tree

6 files changed

+26
-12
lines changed

6 files changed

+26
-12
lines changed

.github/workflows/linter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
DEFAULT_BRANCH: main
4444
FILTER_REGEX_EXCLUDE: dist/**/*
4545
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46-
TYPESCRIPT_DEFAULT_STYLE: prettier
4746
VALIDATE_ALL_CODEBASE: true
4847
VALIDATE_JAVASCRIPT_STANDARD: false
48+
VALIDATE_TYPESCRIPT_STANDARD: false
4949
VALIDATE_JSCPD: false

__tests__/main.test.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,23 @@ const tmpDir = fs.mkdtempSync(
2626
// Mock the GitHub Actions core library
2727
let errorMock: jest.SpiedFunction<typeof core.error>
2828
let getInputMock: jest.SpiedFunction<typeof core.getInput>
29+
let setOutputMock: jest.SpiedFunction<typeof core.setOutput>
2930

3031
describe('action', () => {
3132
beforeEach(() => {
3233
jest.clearAllMocks()
3334

3435
errorMock = jest.spyOn(core, 'error').mockImplementation()
3536
getInputMock = jest.spyOn(core, 'getInput').mockImplementation()
37+
setOutputMock = jest.spyOn(core, 'setOutput').mockImplementation()
3638
})
3739

3840
it('downloads 14.0.0', async () => {
3941
// Set the action's inputs as return values from core.getInput()
4042
getInputMock.mockImplementation(name => {
4143
switch (name) {
4244
case 'version':
43-
return '15.0.0-beta1'
45+
return '14.0.0'
4446
case 'unzip-to':
4547
return tmpDir
4648
default:
@@ -51,5 +53,14 @@ describe('action', () => {
5153
await main.run()
5254
expect(runMock).toHaveReturned()
5355
expect(errorMock).not.toHaveBeenCalled()
56+
57+
expect(setOutputMock).toHaveBeenCalledWith(
58+
'path',
59+
expect.stringContaining(tmpDir)
60+
)
61+
expect(setOutputMock).toHaveBeenCalledWith(
62+
'path-with-slashes',
63+
expect.not.stringContaining('\\')
64+
)
5465
})
5566
})

badges/coverage.svg

Lines changed: 1 addition & 1 deletion
Loading

dist/index.js

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

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.

src/main.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ async function downloadQtC(urls: string[]): Promise<string[]> {
3838
try {
3939
for (const packageName of packages) {
4040
const fullUrl = `${url}/${packageName}`
41-
console.log(`Downloading ${fullUrl}`)
41+
core.info(`Downloading ${fullUrl}`)
4242
await downloadPackage(fullUrl, `${tmpDir}/${packageName}`)
4343
}
4444
return packages.map(packageName => `${tmpDir}/${packageName}`)
@@ -101,16 +101,19 @@ export async function run(): Promise<void> {
101101

102102
for (const packageFile of packages) {
103103
// Unzip the downloaded file
104-
console.log(`Unzipping package: ${packageFile}`)
104+
core.info(`Unzipping package: ${packageFile}`)
105105
await extract(packageFile, destination)
106106
}
107107

108-
console.log(`Qt Creator ${version} has been extracted to ${destination}`)
108+
core.info(`Qt Creator ${version} has been extracted to ${destination}`)
109109

110110
// Set outputs for other workflow steps to use
111111
core.setOutput('path', destination)
112+
core.setOutput(
113+
'path-with-slashes',
114+
path.resolve(destination).split(path.sep).join('/')
115+
)
112116
} catch (error) {
113-
console.log('Error:', error)
114117
// Fail the workflow run if an error occurs
115118
if (error instanceof Error) core.setFailed(error.message)
116119
}

0 commit comments

Comments
 (0)