Skip to content

Commit d91603f

Browse files
add cli version setting
1 parent 1ca4159 commit d91603f

3 files changed

Lines changed: 9 additions & 2 deletions

File tree

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,11 @@
310310
"type": "string",
311311
"description": "API Personal Token"
312312
},
313+
"codacy.cliVersion": {
314+
"type": "string",
315+
"description": "The version of the Codacy CLI to use",
316+
"default": "1.0.0-main.232.a6a6368"
317+
},
313318
"codacy.analysisMode": {
314319
"type": "string",
315320
"title": "Local code analysis",

src/commands/installAnalysisCLI.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ const MAX_BUFFER_SIZE = 1024 * 1024 * 10
1515

1616
const execAsync = (command: string) => {
1717
const workspacePath = vscode.workspace.workspaceFolders?.[0]?.uri.fsPath || ''
18+
const cliVersion = vscode.workspace.getConfiguration().get('codacy.cliVersion')
1819

1920
return new Promise((resolve, reject) => {
2021
exec(
21-
`CODACY_CLI_V2_VERSION=1.0.0-main.232.a6a6368 ${command}`,
22+
`${cliVersion ? `CODACY_CLI_V2_VERSION=${cliVersion}` : ''} ${command}`,
2223
{
2324
cwd: workspacePath,
2425
maxBuffer: MAX_BUFFER_SIZE, // To solve: stdout maxBuffer exceeded

src/commands/runCodacyAnalyze.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export async function runCodacyAnalyze(filePath?: string) {
1818
try {
1919
// Get workspace folder (to solve: mkdir error)
2020
const workspaceFolders = vscode.workspace.workspaceFolders
21+
const cliVersion = vscode.workspace.getConfiguration().get('codacy.cliVersion')
2122
if (!workspaceFolders || workspaceFolders.length === 0) {
2223
throw new Error('No workspace folder found')
2324
}
@@ -27,7 +28,7 @@ export async function runCodacyAnalyze(filePath?: string) {
2728
const relativeFilePath = sanitizeFilePath(workspaceRoot, filePath)
2829

2930
// Construct the command
30-
const command = `CODACY_CLI_V2_VERSION=1.0.0-main.232.a6a6368 .codacy/cli.sh analyze --format sarif ${
31+
const command = `${cliVersion ? `CODACY_CLI_V2_VERSION=${cliVersion}` : ''} .codacy/cli.sh analyze --format sarif ${
3132
relativeFilePath || ''
3233
}`
3334

0 commit comments

Comments
 (0)