Skip to content

Commit

Permalink
fix(GH-19): Split arguments that are known to contain a space
Browse files Browse the repository at this point in the history
  • Loading branch information
gavanlamb committed Jun 16, 2024
1 parent 541f226 commit 2cc7a2d
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 31 deletions.
33 changes: 22 additions & 11 deletions __tests__/services/dotnetService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,20 @@ describe("listOutdatedPackages", () => {
'--include-prerelease',
'--highest-minor',
'--highest-patch',
'--source source1',
'--source source2',
'--config nuget.config',
'--framework net5.0',
'--framework net6.0',
'--format json',
'--verbosity q'
'--source',
'source1',
'--source',
'source2',
'--config',
'nuget.config',
'--framework',
'net5.0',
'--framework',
'net6.0',
'--format',
'json',
'--verbosity',
'q'
];

const { listOutdatedPackages } = await import("../../src/services/dotnetService");
Expand Down Expand Up @@ -249,8 +256,10 @@ describe("listOutdatedPackages", () => {
'list',
'package',
'--outdated',
'--format json',
'--verbosity q'
'--format',
'json',
'--verbosity',
'q'
];

const { listOutdatedPackages } = await import("../../src/services/dotnetService");
Expand Down Expand Up @@ -307,8 +316,10 @@ describe("listOutdatedPackages", () => {
'list',
'package',
'--outdated',
'--format json',
'--verbosity q'
'--format',
'json',
'--verbosity',
'q'
];

const { listOutdatedPackages } = await import("../../src/services/dotnetService");
Expand Down
25 changes: 16 additions & 9 deletions dist/index.js

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

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

27 changes: 17 additions & 10 deletions src/services/dotnetService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,24 @@ function getNuGetSourceArguments(): string[] {
const values = getStringArrayInput('nuget-sources');
const sources: string[] = [];
for (const value of values){
sources.push(`--source ${value}`);
sources.push(`--source`);
sources.push(`${value}`);
}
return sources;
}

/**
* Gets the packages-to-exclude argument from the action
* @returns --exclude {packages} if the argument is set.
* @returns array containing '--config' and '{config}; if the argument is set.
*/
function getNuGetConfigArgument(): string {
function getNuGetConfigArgument(): string[] {
const value = getStringInput('nuget-config-file-path');
if (value)
return `--config ${value}`;
return '';
const config: string[] = [];
if (value) {
config.push(`--config`);
config.push(`${value}`);
}
return config;
}

/**
Expand All @@ -100,7 +104,8 @@ function getFrameworkArguments(): string[] {
const values = getStringArrayInput('frameworks');
const sources: string[] = [];
for (const value of values){
sources.push(`--framework ${value}`);
sources.push(`--framework`);
sources.push(`${value}`);
}
return sources;
}
Expand All @@ -120,10 +125,12 @@ async function listOutdatedPackages(): Promise<Configuration> {
getIncludeHighestMinorOnlyArgument(),
getIncludeHighestPatchOnlyArgument(),
...getNuGetSourceArguments(),
getNuGetConfigArgument(),
...getNuGetConfigArgument(),
...getFrameworkArguments(),
'--format json',
'--verbosity q'
'--format',
'json',
'--verbosity',
'q'
].filter(arg => arg !== '');

debug(`Going to execute "dotnet ${args.join(" ")}"`);
Expand Down

0 comments on commit 2cc7a2d

Please sign in to comment.