Skip to content

Commit

Permalink
Merge pull request #101 from snyk/fix/go-binary-explicit-error
Browse files Browse the repository at this point in the history
fix: go binary explicit error
  • Loading branch information
danlucian authored Sep 1, 2022
2 parents ac4d74d + d0b0595 commit 161eb0c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as fs from 'fs';
import * as path from 'path';
import * as tmp from 'tmp';
import { lookpath } from 'lookpath';
import debugLib = require('debug');
import * as graphlib from '@snyk/graphlib';
import { DepGraphBuilder, DepGraph } from '@snyk/dep-graph';
Expand Down Expand Up @@ -43,6 +44,11 @@ interface Options {
export async function inspect(root, targetFile, options: Options = {}) {
options.debug ? debugLib.enable('snyk-go-plugin') : debugLib.disable();

const goPath = await lookpath('go');
if (!goPath) {
throw new Error('The "go" command is not available on your system. To scan your dependencies in the CLI, you must ensure you have first installed the relevant package manager.');
}

const result = await Promise.all([
getMetaData(root, targetFile),
getDependencies(root, targetFile, options.args),
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@snyk/dep-graph": "^1.23.1",
"@snyk/graphlib": "2.1.9-patch.3",
"debug": "^4.1.1",
"lookpath": "^1.2.2",
"snyk-go-parser": "1.4.1",
"tmp": "0.2.1",
"tslib": "^1.10.0"
Expand Down

0 comments on commit 161eb0c

Please sign in to comment.