Skip to content

Commit 307d94c

Browse files
Add arguments for verbose output to installer script
1 parent c2fa09f commit 307d94c

File tree

6 files changed

+391
-293
lines changed

6 files changed

+391
-293
lines changed

__tests__/installer.test.ts

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,72 @@ describe('installer tests', () => {
251251
}
252252
);
253253

254+
it(`should supply 'verbose' argument to the installation script if verbose input is set to true`, async () => {
255+
const inputVersion = '10.0.101';
256+
const inputQuality = '' as QualityOptions;
257+
const inputVerbose = true;
258+
const stdout = `Fictitious dotnet version ${inputVersion} is installed`;
259+
260+
getExecOutputSpy.mockImplementation(() => {
261+
return Promise.resolve({
262+
exitCode: 0,
263+
stdout: `${stdout}`,
264+
stderr: ''
265+
});
266+
});
267+
maxSatisfyingSpy.mockImplementation(() => inputVersion);
268+
269+
const dotnetInstaller = new installer.DotnetCoreInstaller(
270+
inputVersion,
271+
inputQuality,
272+
undefined,
273+
inputVerbose
274+
);
275+
276+
await dotnetInstaller.installDotnet();
277+
278+
const scriptArguments = getExecOutputSpy.mock.calls.map(call =>
279+
(call[1] as string[]).join(' ')
280+
);
281+
const expectedArgument = IS_WINDOWS ? '-Verbose' : '--verbose';
282+
283+
expect(scriptArguments[0]).toContain(expectedArgument);
284+
expect(scriptArguments[1]).toContain(expectedArgument);
285+
});
286+
287+
it(`should not supply 'verbose' argument to the installation script if verbose input is set to false`, async () => {
288+
const inputVersion = '10.0.101';
289+
const inputQuality = '' as QualityOptions;
290+
const inputVerbose = false;
291+
const stdout = `Fictitious dotnet version ${inputVersion} is installed`;
292+
293+
getExecOutputSpy.mockImplementation(() => {
294+
return Promise.resolve({
295+
exitCode: 0,
296+
stdout: `${stdout}`,
297+
stderr: ''
298+
});
299+
});
300+
maxSatisfyingSpy.mockImplementation(() => inputVersion);
301+
302+
const dotnetInstaller = new installer.DotnetCoreInstaller(
303+
inputVersion,
304+
inputQuality,
305+
undefined,
306+
inputVerbose
307+
);
308+
309+
await dotnetInstaller.installDotnet();
310+
311+
const scriptArguments = getExecOutputSpy.mock.calls.map(call =>
312+
(call[1] as string[]).join(' ')
313+
);
314+
const expectedArgument = IS_WINDOWS ? '-Verbose' : '--verbose';
315+
316+
expect(scriptArguments[0]).not.toContain(expectedArgument);
317+
expect(scriptArguments[1]).not.toContain(expectedArgument);
318+
});
319+
254320
if (IS_WINDOWS) {
255321
it(`should supply '-ProxyAddress' argument to the installation script if env.variable 'https_proxy' is set`, async () => {
256322
process.env['https_proxy'] = 'https://proxy.com';

action.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ inputs:
2020
cache:
2121
description: 'Optional input to enable caching of the NuGet global-packages folder'
2222
required: false
23-
default: false
23+
default: 'false'
2424
cache-dependency-path:
2525
description: 'Used to specify the path to a dependency file: packages.lock.json. Supports wildcards or a list of file names for caching multiple dependencies.'
2626
required: false
@@ -30,6 +30,10 @@ inputs:
3030
architecture:
3131
description: 'Optional architecture for the .NET install. Supported values: x64, x86, arm64, amd64, arm, s390x, ppc64le, riscv64. If not set, the installer auto-detects the current system architecture.'
3232
required: false
33+
verbose:
34+
description: 'Optional input to enable verbose output of installer script'
35+
required: false
36+
default: 'false'
3337
outputs:
3438
cache-hit:
3539
description: 'A boolean value to indicate if a cache was hit.'

0 commit comments

Comments
 (0)