Skip to content

Commit fbd1909

Browse files
committed
fix(TS): Added some better error handling and removed an accidental default value for a field.
1 parent 50c8e5c commit fbd1909

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

tasks/synopsys-detect-task/task.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "5e9b6b5e-3130-47dc-89c5-77a58949f2cf",
33
"name": "SynopsysDetectTask",
4-
"friendlyName": "Synopsys Detect QA",
4+
"friendlyName": "Synopsys Detect Dev",
55
"description": "Execute Synopsys Detect against your build",
66
"author": "Synopsys",
77
"category": "Utility",
@@ -13,7 +13,7 @@
1313
"version": {
1414
"Major": 7,
1515
"Minor": 0,
16-
"Patch": 3
16+
"Patch": 24
1717
},
1818
"minimumAgentVersion": "1.95.0",
1919
"instanceNameFormat": "Run Synopsys Detect for your build $(message)",
@@ -81,7 +81,7 @@
8181
{
8282
"name": "DetectAirGapJarDirectoryPath",
8383
"type": "string",
84-
"defaultValue": "Agent.ToolsDirectory",
84+
"defaultValue": "",
8585
"label": "Detect Air Gap Jar Directory Path",
8686
"required": true,
8787
"helpMarkDown": "The extracted Detect jar directory path that will be used for Air Gap mode.",
@@ -93,4 +93,4 @@
9393
"target": "detect-task.js"
9494
}
9595
}
96-
}
96+
}

tasks/synopsys-detect-task/ts/runner/DetectJarConfigurationRunner.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,17 @@ export class DetectJarConfigurationRunner extends DetectRunner {
1919
}
2020

2121
createRunnerConfiguration(): IDetectRunnerConfiguration {
22+
logger.info('Checking jar directory.')
23+
if (!fileSystem.existsSync(this.jarDirectoryPath)) {
24+
throw new Error(`Directory did not exist '${this.jarDirectoryPath}'`);
25+
}
26+
2227
const firstJarFile: string = fileSystem.readdirSync(this.jarDirectoryPath)
2328
.find(file => DetectJarConfigurationRunner.JAR_EXTENSION === path.parse(file).ext) || ''
2429

2530
if (!firstJarFile || !firstJarFile.startsWith(DetectJarConfigurationRunner.JAR_PREFIX)) {
2631
logger.warn('Should have only the detect jar in this directory.')
27-
logger.error(`Was unable to find valid jar in ${this.jarDirectoryPath}.`)
28-
29-
return {
30-
fileName: '',
31-
runCommands: [],
32-
runnerTool: ''
33-
}
32+
throw new Error(`Was unable to find valid jar in ${this.jarDirectoryPath}.`)
3433
} else {
3534
logger.info(`Found jar file '${firstJarFile}'`)
3635
}

tasks/synopsys-detect-task/ts/runner/DetectRunner.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ export abstract class DetectRunner {
2626
logger.info('Setting up the env to run Detect...')
2727
const detectSetup = this.setupDetect()
2828
const env = detectSetup.getEnv()
29+
2930
logger.info('Parsing detect arguments...')
3031
const cleanedArguments: string[] = detectSetup.convertArgumentsToPassableValues()
3132
const config: IDetectRunnerConfiguration = this.createRunnerConfiguration()
33+
3234
logger.info('Determining folder where Detect is located...')
3335
const artifactFolder: string = await this.retrieveOrCreateArtifactFolder(config.fileName)
34-
const toolRunner = new ADOToolRunner(config)
3536

37+
const toolRunner = new ADOToolRunner(config)
3638
return await toolRunner.invoke(cleanedArguments, artifactFolder, env)
3739
}
3840
}

vss-extension.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"manifestVersion": 1,
3-
"id": "synopsys-detect-qa",
4-
"version": "7.0.3",
5-
"name": "Synopsys Detect QA",
3+
"id": "synopsys-detect-dev",
4+
"version": "7.0.24",
5+
"name": "Synopsys Detect Dev",
66
"publisher": "synopsys-detect",
77
"public": false,
88
"targets": [
@@ -146,4 +146,4 @@
146146
}
147147
}
148148
]
149-
}
149+
}

0 commit comments

Comments
 (0)