Skip to content

Commit

Permalink
[#3] Remove hardcoded snyk path (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
asos-craigmorten authored Dec 16, 2021
1 parent f8e9e2f commit 4da1ea9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
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

0 comments on commit 4da1ea9

Please sign in to comment.