Skip to content

Commit

Permalink
feat: add -p as alias for --prune-repeated-subdependencies
Browse files Browse the repository at this point in the history
add alias -p for --prune-repeated-subdependencies
convert `prune-repeated-subdependencies` internally to camel case
  • Loading branch information
lili2311 committed Aug 19, 2020
1 parent a5c9ec4 commit 16dc73f
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion help/help.txt
Expand Up @@ -66,7 +66,7 @@ Options:
-v, --version ...... The CLI version.
--print-deps ....... (test and monitor commands only)
Print the dependency tree before sending it for analysis.
--prune-repeated-subdependencies
-p, --prune-repeated-subdependencies
(test and monitor command only)
Prune dependency trees, removing duplicate sub-dependencies.
Will still find all vulnerabilities, but potentially not all
Expand Down
2 changes: 2 additions & 0 deletions src/cli/args.ts
Expand Up @@ -26,6 +26,7 @@ const alias = abbrev(
);
alias.d = 'debug'; // always make `-d` debug
alias.t = 'test';
alias.p = 'prune-repeated-subdependencies';

// The -d flag enables printing the messages for predefined namespaces.
// Additional ones can be specified (comma-separated) in the DEBUG environment variable.
Expand Down Expand Up @@ -202,6 +203,7 @@ export function args(rawArgv: string[]): Args {
'reachable-vulns-timeout',
'integration-name',
'integration-version',
'prune-repeated-subdependencies',
];
for (const dashedArg of argumentsToTransform) {
if (argv[dashedArg]) {
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/monitor/index.ts
Expand Up @@ -304,7 +304,7 @@ function generateMonitorMeta(options, packageManager?): MonitorMeta {
'policy-path': options['policy-path'],
'project-name': options['project-name'] || config.PROJECT_NAME,
isDocker: !!options.docker,
prune: !!options['prune-repeated-subdependencies'],
prune: !!options.pruneRepeatedSubdependencies,
'experimental-dep-graph': !!options['experimental-dep-graph'],
'remote-repo-url': options['remote-repo-url'],
};
Expand Down
2 changes: 1 addition & 1 deletion src/lib/snyk-test/run-test.ts
Expand Up @@ -521,7 +521,7 @@ async function assembleLocalPayloads(
});
}

const pruneIsRequired = options['prune-repeated-subdependencies'];
const pruneIsRequired = options.pruneRepeatedSubdependencies;

if (packageManager) {
depGraph = await pruneGraph(
Expand Down
4 changes: 2 additions & 2 deletions src/lib/types.ts
Expand Up @@ -15,7 +15,7 @@ export type ShowVulnPaths = 'none' | 'some' | 'all';
export interface TestOptions {
traverseNodeModules: boolean;
interactive: boolean;
'prune-repeated-subdependencies'?: boolean;
pruneRepeatedSubdependencies?: boolean;
showVulnPaths: ShowVulnPaths;
failOn?: FailOn;
reachableVulns?: boolean;
Expand Down Expand Up @@ -87,7 +87,7 @@ export interface MonitorOptions {
scanAllUnmanaged?: boolean;
allProjects?: boolean;
// An experimental flag to allow monitoring of bigtrees (with degraded deps info and remediation advice).
'prune-repeated-subdependencies'?: boolean;
pruneRepeatedSubdependencies?: boolean;
// Used with the Docker plugin only. Allows requesting some experimental/unofficial features.
experimental?: boolean;
// Used with the Docker plugin only. Allows application scanning.
Expand Down
4 changes: 2 additions & 2 deletions test/acceptance/cli-monitor/cli-monitor.acceptance.test.ts
Expand Up @@ -240,7 +240,7 @@ if (!isWindows) {
chdirWorkspaces();

await cli.monitor('npm-package-pruneable', {
'prune-repeated-subdependencies': true,
pruneRepeatedSubdependencies: true,
});
const req = server.popRequest();
t.equal(req.method, 'PUT', 'makes PUT request');
Expand Down Expand Up @@ -271,7 +271,7 @@ if (!isWindows) {
chdirWorkspaces();

await cli.monitor('npm-package-pruneable', {
'prune-repeated-subdependencies': true,
pruneRepeatedSubdependencies: true,
'experimental-dep-graph': true,
});
const req = server.popRequest();
Expand Down

0 comments on commit 16dc73f

Please sign in to comment.