Skip to content

Commit

Permalink
fix: muncher validation (#133)
Browse files Browse the repository at this point in the history
💥
  • Loading branch information
ButterB0wl authored and DarthHater committed Jan 23, 2020
1 parent 80d09fd commit 0686b61
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
4 changes: 1 addition & 3 deletions src/Application/Application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ import { filterVulnerabilities } from '../Whitelist/VulnerabilityExcluder';
import { IqServerConfig } from '../Config/IqServerConfig';
import { OssIndexServerConfig } from '../Config/OssIndexServerConfig';

const pack = require('../../package.json');

export class Application {
private results: Array<Coordinates> = new Array();
private sbom: string = "";
Expand Down Expand Up @@ -65,7 +63,7 @@ export class Application {
this.muncher = bower;
}
else {
logMessage('Could not instantiate muncher', 'error');
logMessage('Failed project directory validation. Are you in a (built) node, yarn, or bower project directory?', 'error');
throw new Error("Could not instantiate muncher");
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Munchers/NpmList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export class NpmList implements Muncher {
}

public isValid(): boolean {
let tempPath = path.join(process.cwd(), "package-lock.json");
return fs.existsSync(tempPath);
let nodeModulesPath = path.join(process.cwd(), "node_modules");
return fs.existsSync(nodeModulesPath);
}

// TODO: There is a 1 component discrepency in what gets identified by our installed deps implementation
Expand Down
16 changes: 10 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,16 @@ if (argv) {
}

let app: Application;

if (argv.dev) {
app = new Application(argv.dev as boolean, silence, artie);
} else {
app = new Application(false, silence, artie);
try {
if (argv.dev) {
app = new Application(argv.dev as boolean, silence, artie);
} else {
app = new Application(false, silence, artie);
}
app.startApplication(argv);
}
catch(error) {
console.error(error.message);
}
app.startApplication(argv);
}
}

0 comments on commit 0686b61

Please sign in to comment.