Skip to content

Commit

Permalink
fix: wizard support for multi result
Browse files Browse the repository at this point in the history
BST-939
The multi result change introduced in 1.232.0 causes wizard to error
This fix passes first scan result to monitor
  • Loading branch information
lili2311 authored and gitphill committed Oct 10, 2019
1 parent 27697eb commit 17f5a3a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
13 changes: 10 additions & 3 deletions src/cli/commands/protect/wizard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { MissingTargetFileError } from '../../../lib/errors/missing-targetfile-e
import * as pm from '../../../lib/package-managers';
import { Options, MonitorMeta, MonitorResult } from '../../../lib/types';
import { LegacyVulnApiResult } from '../../../lib/snyk-test/legacy';
import { SinglePackageResult } from '@snyk/cli-interface/legacy/plugin';

function wizard(options?: Options) {
options = options || ({} as Options);
Expand Down Expand Up @@ -593,13 +594,19 @@ function processAnswers(answers, policy, options) {
options.traverseNodeModules = false;
}

// TODO: extract common inspect & monitor code and use the same way here
// as during test & monitor
return (
info
.inspect(cwd, targetFile, options)
.then((inspectRes) => spinner(lbl).then(() => inspectRes))
.then((inspectRes) =>
snykMonitor(cwd, meta as MonitorMeta, inspectRes),
)
.then((inspectRes) => {
const singleRes: SinglePackageResult = {
plugin: inspectRes.plugin,
package: _.get(inspectRes, 'scannedProjects[0].depTree'),
};
return snykMonitor(cwd, meta as MonitorMeta, singleRes);
})
// clear spinner in case of success or failure
.then(spinner.clear(lbl))
.catch((error) => {
Expand Down
1 change: 0 additions & 1 deletion src/lib/project-metadata/target-builders/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { GitTarget } from '../types';

export async function getInfo(packageInfo): Promise<GitTarget | null> {
let origin: string | null | undefined;

if (packageInfo.docker) {
return null;
}
Expand Down

0 comments on commit 17f5a3a

Please sign in to comment.