Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#3] Remove hardcoded snyk path #4

Merged
merged 6 commits into from
Dec 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# ChangeLog

## [4.0.2] - 16-12-2021

- fix: don't rely on hardcoded paths to `snyk` binary

## [4.0.1] - 14-12-2021

- docs: fix readme instructions to use `@asos` scope
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@asos/snyker",
"version": "4.0.1",
"version": "4.0.2",
"description": "An opinionated, heavy-handed wrapper around Snyk.",
"author": {
"name": "Craig Morten",
Expand All @@ -24,6 +24,9 @@
"doc": "docs",
"lib": "lib"
},
"engines": {
"npm": ">=5.2.0"
},
"main": "lib/index.js",
"bin": {
"snyker": "bin/snyker"
Expand Down
12 changes: 5 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,6 @@ const snyker = async () => {

const lockFileName = argv.lockfile || "yarn.lock";
const isYarn = lockFileName.includes("yarn");
const snykCliPath = path.join(
path.dirname(module.id),
"../node_modules/.bin/snyk"
);

console.log(
`[SNYKER: STEP 1]: Ensuring lockfile '${lockFileName}' is up to date.\n`
Expand Down Expand Up @@ -307,7 +303,8 @@ const snyker = async () => {
console.log("[SNYKER: STEP 3]: Getting vulnerable paths from Snyk.");

const depsToForceUpdate = await catchAndRetry(async () => {
const { stdout: snykTestOut } = await exec(snykCliPath, [
const { stdout: snykTestOut } = await exec("npx", [
"snyk",
"test",
"--dev",
"--json",
Expand Down Expand Up @@ -347,7 +344,8 @@ const snyker = async () => {
);

const finalVulnerabilities = await catchAndRetry(async () => {
const { stdout: finalSnykTestOut } = await exec(snykCliPath, [
const { stdout: finalSnykTestOut } = await exec("npx", [
"snyk",
"test",
"--dev",
"--json",
Expand Down Expand Up @@ -405,7 +403,7 @@ const snyker = async () => {
console.log();

for (const id of uniqueVulnerabilityIds) {
await exec(snykCliPath, ["ignore", `--id=${id}`]);
await exec("npx", ["snyk", "ignore", `--id=${id}`]);
}

if (upgradablePackages.length) {
Expand Down