Skip to content

Commit

Permalink
feat: silence noisy error behind -d for --all-projects
Browse files Browse the repository at this point in the history
  • Loading branch information
lili2311 committed Mar 19, 2020
1 parent 500197b commit dcb918a
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/cli/commands/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
getSeverityValue,
} from './formatters';

const debug = Debug('snyk');
const debug = Debug('snyk-test');
const SEPARATOR = '\n-------------------------------------------------------\n';

const showVulnPathsMapping: Record<string, ShowVulnPaths> = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { legacyPlugin as pluginApi } from '@snyk/cli-interface';
import { MultiProjectResultCustom } from './get-multi-plugin-result';
import { SupportedPackageManagers } from '../package-managers';
import { PluginMetadata } from '@snyk/cli-interface/legacy/plugin';

export function convertSingleResultToMultiCustom(
inspectRes: pluginApi.SinglePackageResult,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/plugins/get-deps-from-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import analytics = require('../analytics');
import { convertSingleResultToMultiCustom } from './convert-single-splugin-res-to-multi-custom';
import { convertMultiResultToMultiCustom } from './convert-multi-plugin-res-to-multi-custom';

const debug = debugModule('snyk');
const debug = debugModule('snyk-test');

// Force getDepsFromPlugin to return scannedProjects for processing
export async function getDepsFromPlugin(
Expand Down
5 changes: 4 additions & 1 deletion src/lib/plugins/get-multi-plugin-result.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import * as _ from 'lodash';
import * as path from 'path';
import * as cliInterface from '@snyk/cli-interface';
import chalk from 'chalk';
import * as debugModule from 'debug';

import { TestOptions, Options, MonitorOptions } from '../types';
import { detectPackageManagerFromFile } from '../detect';
Expand All @@ -10,6 +12,7 @@ import { convertSingleResultToMultiCustom } from './convert-single-splugin-res-t
import { convertMultiResultToMultiCustom } from './convert-multi-plugin-res-to-multi-custom';
import { PluginMetadata } from '@snyk/cli-interface/legacy/plugin';

const debug = debugModule('snyk-test');
export interface ScannedProjectCustom
extends cliInterface.legacyCommon.ScannedProject {
packageManager: SupportedPackageManagers;
Expand Down Expand Up @@ -63,7 +66,7 @@ export async function getMultiPluginResult(

allResults.push(...pluginResultWithCustomScannedProjects.scannedProjects);
} catch (err) {
console.log(err);
debug(chalk.bold.red(err.message));
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib/plugins/nodejs-plugin/npm-lock-parser.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as baseDebug from 'debug';
const debug = baseDebug('snyk');
const debug = baseDebug('snyk-test');
import * as path from 'path';
import * as spinner from '../../spinner';
import * as analytics from '../../analytics';
Expand Down
16 changes: 10 additions & 6 deletions src/lib/sub-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ export function execute(
let stderr = '';

const proc = childProcess.spawn(command, args, spawnOptions);
proc.stdout.on('data', (data) => {
stdout = stdout + data;
});
proc.stderr.on('data', (data) => {
stderr = stderr + data;
});
if (proc.stdout) {
proc.stdout.on('data', (data) => {
stdout += data;
});
}
if (proc.stderr) {
proc.stderr.on('data', (data) => {
stderr += data;
});
}

proc.on('close', (code) => {
if (code !== 0) {
Expand Down

0 comments on commit dcb918a

Please sign in to comment.