Skip to content

Commit

Permalink
feat: convert nodejs to use multi format
Browse files Browse the repository at this point in the history
  • Loading branch information
lili2311 committed Oct 2, 2019
1 parent c965884 commit 468ec63
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/lib/plugins/nodejs-plugin/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import * as modulesParser from './npm-modules-parser';
import * as lockParser from './npm-lock-parser';
import * as types from '../types';
import { MissingTargetFileError } from '../../errors/missing-targetfile-error';
import { MultiProjectResult } from '@snyk/cli-interface/legacy/plugin';

export async function inspect(
root: string,
targetFile: string,
options: types.Options = {},
): Promise<types.InspectResult> {
): Promise<MultiProjectResult> {
if (!targetFile) {
throw MissingTargetFileError(root);
}
Expand All @@ -16,13 +17,15 @@ export async function inspect(
targetFile.endsWith('yarn.lock');

const getLockFileDeps = isLockFileBased && !options.traverseNodeModules;
const depTree: any = getLockFileDeps
? await lockParser.parse(root, targetFile, options)
: await modulesParser.parse(root, targetFile, options);

return {
plugin: {
name: 'snyk-nodejs-lockfile-parser',
runtime: process.version,
},
package: getLockFileDeps
? await lockParser.parse(root, targetFile, options)
: await modulesParser.parse(root, targetFile, options),
scannedProjects: [{ depTree }],
};
}
1 change: 1 addition & 0 deletions src/lib/plugins/rubygems/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export async function inspect(
name: 'bundled:rubygems',
runtime: 'unknown',
},
// TODO: must be a depTree!
package: {
name: specs.packageName,
targetFile: specs.targetFile,
Expand Down

0 comments on commit 468ec63

Please sign in to comment.