Skip to content

Commit

Permalink
fix: monitor graph by default if enabled for nom and sbt
Browse files Browse the repository at this point in the history
  • Loading branch information
lili2311 committed Dec 13, 2019
1 parent eb4e422 commit 4e29c12
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 19 deletions.
19 changes: 1 addition & 18 deletions src/cli/commands/monitor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,6 @@ async function monitor(...args0: MethodArgs): Promise<any> {

apiTokenExists();

if (options['experimental-dep-graph']) {
const isFFSupported = await isFeatureFlagSupportedForOrg(
_.camelCase('experimental-dep-graph'),
);

if (isFFSupported.code === 401) {
throw AuthFailedError(isFFSupported.error, isFFSupported.code);
}

if (!isFFSupported.ok) {
throw new UnsupportedFeatureFlagError(
'experimental-dep-graph',
isFFSupported.userMessage,
);
}
}

// Part 1: every argument is a scan target; process them sequentially
for (const path of args as string[]) {
try {
Expand Down Expand Up @@ -156,7 +139,7 @@ async function monitor(...args0: MethodArgs): Promise<any> {
}
const meta: MonitorMeta = {
method: 'cli',
packageManager: packageManager,
packageManager,
'policy-path': options['policy-path'],
'project-name': options['project-name'] || config.PROJECT_NAME,
isDocker: !!options.docker,
Expand Down
7 changes: 6 additions & 1 deletion src/lib/monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { MonitorError, ConnectionTimeoutError } from './errors';
import { countPathsToGraphRoot, pruneGraph } from './prune';
import { GRAPH_SUPPORTED_PACKAGE_MANAGERS } from './package-managers';
import { legacyPlugin as pluginApi } from '@snyk/cli-interface';
import { isFeatureFlagSupportedForOrg } from './feature-flags';

const debug = Debug('snyk');

Expand Down Expand Up @@ -148,8 +149,12 @@ export async function monitor(
analytics.add('packageManager', packageManager);
analytics.add('isDocker', !!meta.isDocker);

const monitorGraphSupportedRes = await isFeatureFlagSupportedForOrg(
_.camelCase('experimental-dep-graph'),
);

if (
meta['experimental-dep-graph'] &&
monitorGraphSupportedRes &&
GRAPH_SUPPORTED_PACKAGE_MANAGERS.includes(packageManager)
) {
return await monitorGraph(root, meta, info, targetFile);
Expand Down

0 comments on commit 4e29c12

Please sign in to comment.