-
Notifications
You must be signed in to change notification settings - Fork 565
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5490 from snyk/fix/add-normalize-help-for-derivin…
…g-target-files fix: add normalize help for deriving target files [CLI-448]
- Loading branch information
Showing
5 changed files
with
54 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import type { PluginMetadata } from '@snyk/cli-interface/legacy/plugin'; | ||
import type { ScannedProjectCustom } from './plugins/get-multi-plugin-result'; | ||
import type { ScannedProject } from '@snyk/cli-interface/legacy/common'; | ||
|
||
/** | ||
* Normalizes the target file path for a scanned project across | ||
* test and monitor workflows. | ||
* | ||
* @param {ScannedProject | ScannedProjectCustom} scannedProject - The scanned project containing metadata such as the target file path. | ||
* @param {PluginMetadata} plugin - Metadata about the plugin used to scan the project, which may also include the target file path. | ||
* @param {string} [fallback=''] - A fallback value to return if neither the scanned project nor the plugin contain a target file path. Defaults to an empty string. | ||
* | ||
* @returns {string} - The resolved target file path from either the scanned project, plugin, or the provided fallback value if none are available. | ||
*/ | ||
export function normalizeTargetFile( | ||
scannedProject: ScannedProject | ScannedProjectCustom, | ||
plugin: PluginMetadata, | ||
fallback = '', | ||
): string { | ||
return scannedProject.targetFile || plugin.targetFile || fallback; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters