Skip to content

Commit

Permalink
Merge pull request #1292 from snyk/feat/refactor-project-type-validation
Browse files Browse the repository at this point in the history
chore: simplify supported projects validation on test
  • Loading branch information
lili2311 committed Jul 28, 2020
2 parents d0bc022 + a794bde commit 19e7c79
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions src/lib/snyk-test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,26 @@ function executeTest(root, options) {
}

function run(root, options) {
const projectType = options.packageManager;
validateProjectType(options, projectType);
return runTest(projectType, root, options);
}

function validateProjectType(options, projectType) {
if (options.iac) {
const projectType = options.packageManager;
if (!iacProjects.TEST_SUPPORTED_IAC_PROJECTS.includes(projectType)) {
throw new NotSupportedIacFileError(projectType);
}
return runTest(projectType, root, options);
}

const packageManager = options.packageManager;
if (
!(
options.docker ||
options.allProjects ||
options.yarnWorkspaces ||
pm.SUPPORTED_PACKAGE_MANAGER_NAME[packageManager]
)
) {
throw new UnsupportedPackageManagerError(packageManager);
} else {
if (
!(
options.docker ||
options.allProjects ||
options.yarnWorkspaces ||
pm.SUPPORTED_PACKAGE_MANAGER_NAME[projectType]
)
) {
throw new UnsupportedPackageManagerError(projectType);
}
}
return runTest(packageManager, root, options);
}

0 comments on commit 19e7c79

Please sign in to comment.