diff --git a/src/lib/plugins/index.js b/src/lib/plugins/index.js deleted file mode 100644 index 0c28519706..0000000000 --- a/src/lib/plugins/index.js +++ /dev/null @@ -1,48 +0,0 @@ -module.exports = { - loadPlugin: loadPlugin, -}; - -function loadPlugin(packageManager, options) { - if (options && options.docker) { - return require('snyk-docker-plugin'); - } - switch (packageManager) { - case 'npm': { - return require('./npm'); - } - case 'rubygems': { - return require('./rubygems'); - } - case 'maven': { - return require('snyk-mvn-plugin'); - } - case 'gradle': { - return require('snyk-gradle-plugin'); - } - case 'sbt': { - return require('snyk-sbt-plugin'); - } - case 'yarn': { - return require('./yarn'); - } - case 'pip': { - return require('snyk-python-plugin'); - } - case 'golangdep': - case 'govendor': { - return require('snyk-go-plugin'); - } - case 'nuget': { - return require('snyk-nuget-plugin'); - } - case 'paket': { - return require('snyk-nuget-plugin'); - } - case 'composer': { - return require('snyk-php-plugin'); - } - default: { - throw new Error('Unsupported package manager: ' + packageManager); - } - } -} diff --git a/src/lib/plugins/index.ts b/src/lib/plugins/index.ts new file mode 100644 index 0000000000..02d9b104de --- /dev/null +++ b/src/lib/plugins/index.ts @@ -0,0 +1,76 @@ +import * as dockerPlugin from 'snyk-docker-plugin'; +import * as npmPlugin from './npm'; +import * as rubygemsPlugin from './rubygems'; +import * as mvnPlugin from 'snyk-mvn-plugin'; +import * as gradlePlugin from 'snyk-gradle-plugin'; +import * as sbtPlugin from 'snyk-sbt-plugin'; +import * as yarnPlugin from './yarn'; +import * as pythonPlugin from 'snyk-python-plugin'; +import * as goPlugin from 'snyk-go-plugin'; +import * as nugetPlugin from 'snyk-nuget-plugin'; +import * as phpPlugin from 'snyk-php-plugin'; + +interface InspectResult { + plugin: { + name: string; + runtime: string; + }; + package: any; +} + +interface Options { + docker?: boolean; + traverseNodeModules?: boolean; + dev?: boolean; + strictOutOfSync?: boolean; +} + +interface Plugin { + inspect: (root: string, targetFile: string, options?: Options) => Promise; +} + +export function loadPlugin(packageManager: string, options: Options = {}): Plugin { + if (options.docker) { + return dockerPlugin; + } + + switch (packageManager) { + case 'npm': { + return npmPlugin; + } + case 'rubygems': { + return rubygemsPlugin; + } + case 'maven': { + return mvnPlugin; + } + case 'gradle': { + return gradlePlugin; + } + case 'sbt': { + return sbtPlugin; + } + case 'yarn': { + return yarnPlugin; + } + case 'pip': { + return pythonPlugin; + } + case 'golangdep': + case 'govendor': { + return goPlugin; + } + case 'nuget': { + return nugetPlugin; + } + case 'paket': { + return nugetPlugin; + } + case 'composer': { + return phpPlugin; + } + default: { + throw new Error(`Unsupported package manager: ${packageManager}`); + } + } +} diff --git a/src/lib/plugins/npm/index.js b/src/lib/plugins/npm/index.js deleted file mode 100644 index 358084c8ea..0000000000 --- a/src/lib/plugins/npm/index.js +++ /dev/null @@ -1,70 +0,0 @@ -const snyk = require('../../'); -const fileSystem = require('fs'); -const fs = require('then-fs'); -const path = require('path'); -const lockFileParser = require('snyk-nodejs-lockfile-parser'); -const _ = require('lodash'); - -module.exports = { - inspect, -}; - -function inspect(root, targetFile, options) { - const isLockFileBased = targetFile.endsWith('package-lock.json'); - - const isShrinkwrapPresent = fileSystem.existsSync( - path.resolve(root, targetFile).dir, 'npm-shrinkwrap.json' - ); - if (isLockFileBased && !isShrinkwrapPresent && !options.traverseNodeModules) { - return generateDependenciesFromLockfile(root, options, targetFile) - .then((modules) => ({ - plugin: { - name: 'snyk-nodejs-lockfile-parser', - runtime: process.version, - }, - package: modules, - })); - } - - // old style npm projects - return snyk.modules(root, Object.assign({}, options, {noFromArrays: true})) - .then(function (modules) { - return { - plugin: { - name: 'snyk-resolve-deps', - runtime: process.version, - }, - package: modules, - }; - }); -} - -async function generateDependenciesFromLockfile(root, options, targetFile) { - const lockFileFullPath = path.resolve(root, targetFile); - if (!fileSystem.existsSync(lockFileFullPath)) { - throw new Error('Lockfile ' + targetFile + ' not found at location: ' + - lockFileFullPath); - } - - const fullPath = path.parse(lockFileFullPath); - const manifestFileFullPath = path.resolve(fullPath.dir, 'package.json'); - - if (!fileSystem.existsSync(manifestFileFullPath)) { - throw new Error('Manifest file package.json not found at location: ' + - manifestFileFullPath); - } - - if (!manifestFileFullPath && lockFileFullPath) { - throw new Error('Detected a lockfile at location: ' - + lockFileFullPath + '\n However the package.json is missing!'); - } - - const manifestFile = await fs.readFile(manifestFileFullPath, 'utf-8'); - const lockFile = await fs.readFile(lockFileFullPath, 'utf-8'); - const defaultManifestFileName = path.relative(root, manifestFileFullPath); - - const strictOutOfSync = _.get(options, 'strictOutOfSync', true); - return lockFileParser.buildDepTree(manifestFile, lockFile, options.dev, - lockFileParser.LockfileType.npm, strictOutOfSync, defaultManifestFileName); -} - diff --git a/src/lib/plugins/npm/index.ts b/src/lib/plugins/npm/index.ts new file mode 100644 index 0000000000..19cb696e85 --- /dev/null +++ b/src/lib/plugins/npm/index.ts @@ -0,0 +1,80 @@ +import * as path from 'path'; +import * as fs from 'then-fs'; +import * as _ from 'lodash'; +import {buildDepTree, PkgTree, LockfileType} from 'snyk-nodejs-lockfile-parser'; +import * as snyk from '../../'; + +interface Options { + traverseNodeModules?: boolean; + dev?: boolean; + strictOutOfSync?: boolean; +} + +interface InspectResult { + plugin: { + name: string; + runtime: string; + }; + package: PkgTree; +} + +export async function inspect(root: string, targetFile: string, options: Options = {}): Promise { + const isLockFileBased = targetFile.endsWith('package-lock.json'); + const targetFileFullPath = path.resolve(root, targetFile); + const isShrinkwrapPresent = await fs.exists(path.join(path.dirname(targetFileFullPath), 'npm-shrinkwrap.json')); + + if (isLockFileBased && !isShrinkwrapPresent && !options.traverseNodeModules) { + return { + plugin: { + name: 'snyk-nodejs-lockfile-parser', + runtime: process.version, + }, + package: await generateDependenciesFromLockfile(root, targetFile, options), + }; + } + + // Old style npm projects. + return { + plugin: { + name: 'snyk-resolve-deps', + runtime: process.version, + }, + package: await snyk.modules(root, Object.assign({}, options, {noFromArrays: true})), + }; +} + +async function generateDependenciesFromLockfile(root: string, targetFile: string, options: Options): Promise { + const lockFileFullPath = path.resolve(root, targetFile); + + if (!await fs.exists(lockFileFullPath)) { + throw new Error(`Lockfile ${targetFile} not found at location: ${lockFileFullPath}`); + } + + const fullPath = path.parse(lockFileFullPath); + const manifestFileFullPath = path.resolve(fullPath.dir, 'package.json'); + + if (!await fs.exists(manifestFileFullPath)) { + throw new Error(`Manifest file package.json not found at location: ${manifestFileFullPath}`); + } + + if (!manifestFileFullPath && lockFileFullPath) { + throw new Error(`Detected a lockfile at location: ${lockFileFullPath}\nHowever the package.json is missing!`); + } + + const [manifestFile, lockFile] = await Promise.all([ + await fs.readFile(manifestFileFullPath, 'utf-8'), + await fs.readFile(lockFileFullPath, 'utf-8'), + ]); + + const defaultManifestFileName = path.relative(root, manifestFileFullPath); + const strictOutOfSync = _.get(options, 'strictOutOfSync', true); + + return await buildDepTree( + manifestFile, + lockFile, + options.dev, + LockfileType.npm, + strictOutOfSync, + defaultManifestFileName, + ); +} diff --git a/src/lib/plugins/rubygems/index.js b/src/lib/plugins/rubygems/index.js deleted file mode 100644 index 4af4fc2c1a..0000000000 --- a/src/lib/plugins/rubygems/index.js +++ /dev/null @@ -1,33 +0,0 @@ -var repoInspectors = require('./inspectors'); - -module.exports = { - inspect: inspect, -}; - -function inspect(root, targetFile) { - return gatherSpecs(root, targetFile) - .then(function (specs) { - var pkg = { - name: specs.packageName, - targetFile: specs.targetFile, - files: specs.files, - }; - return { - plugin: { - name: 'bundled:rubygems', - runtime: 'unknown', - }, - package: pkg, - }; - }); -} - -function gatherSpecs(root, targetFile) { - for (var i = repoInspectors.length - 1; i >= 0; i--) { - var inspector = repoInspectors[i]; - if (inspector.canHandle(targetFile)) { - return inspector.gatherSpecs(root, targetFile); - } - } - throw new Error('Could not handle file: ' + targetFile); -} diff --git a/src/lib/plugins/rubygems/index.ts b/src/lib/plugins/rubygems/index.ts new file mode 100644 index 0000000000..0beec03e87 --- /dev/null +++ b/src/lib/plugins/rubygems/index.ts @@ -0,0 +1,39 @@ +import {inspectors, Spec} from './inspectors'; + +interface InspectResult { + plugin: { + name: string; + runtime: string; + }; + package: { + name: string; + targetFile: string; + files: any + }; +} + +export async function inspect(root: string, targetFile: string): Promise { + const specs = await gatherSpecs(root, targetFile); + + return { + plugin: { + name: 'bundled:rubygems', + runtime: 'unknown', + }, + package: { + name: specs.packageName, + targetFile: specs.targetFile, + files: specs.files, + }, + }; +} + +async function gatherSpecs(root, targetFile): Promise { + for (const inspector of inspectors) { + if (inspector.canHandle(targetFile)) { + return await inspector.gatherSpecs(root, targetFile); + } + } + + throw new Error(`Could not handle file: ${targetFile}`); +} diff --git a/src/lib/plugins/rubygems/inspectors/gemfile.js b/src/lib/plugins/rubygems/inspectors/gemfile.js deleted file mode 100644 index 5e1ee8c64b..0000000000 --- a/src/lib/plugins/rubygems/inspectors/gemfile.js +++ /dev/null @@ -1,34 +0,0 @@ -var path = require('path'); -var tryGetSpec = require('./try-get-spec'); -var pattern = /^Gemfile(\.lock)*$/; - -module.exports = { - canHandle: function handles(file) { - return file && pattern.test(path.basename(file)); - }, - - gatherSpecs: function gatherSpecs(root, target) { - var targetName = path.basename(target); - var targetDir = path.dirname(target); - var files = {}; - - var gemfileLock = tryGetSpec(root, path.join(targetDir, 'Gemfile.lock')); - if (gemfileLock) { - files.gemfileLock = gemfileLock; - } else { - throw new Error('Missing Gemfile.lock file: we can\'t test ' + - 'without dependencies.\nPlease run `bundle install` first.'); - } - - var gemfile = tryGetSpec(root, path.join(targetDir, 'Gemfile')); - if (gemfile) { - files.gemfile = gemfile; - } - - return Promise.resolve({ - packageName: path.basename(root), - targetFile: path.join(targetDir, targetName), - files: files, - }); - }, -}; diff --git a/src/lib/plugins/rubygems/inspectors/gemfile.ts b/src/lib/plugins/rubygems/inspectors/gemfile.ts new file mode 100644 index 0000000000..dedc592260 --- /dev/null +++ b/src/lib/plugins/rubygems/inspectors/gemfile.ts @@ -0,0 +1,36 @@ +import * as path from 'path'; +import {Files, tryGetSpec} from './try-get-spec'; +import {Spec} from './index'; + +const pattern = /^Gemfile(\.lock)*$/; + +export function canHandle(file: string): boolean { + return !!file && pattern.test(path.basename(file)); +} + +export async function gatherSpecs(root: string, target: string): Promise { + const targetName = path.basename(target); + const targetDir = path.dirname(target); + const files: Files = {}; + + const gemfileLock = await tryGetSpec(root, path.join(targetDir, 'Gemfile.lock')); + + if (gemfileLock) { + files.gemfileLock = gemfileLock; + } else { + throw new Error('Missing Gemfile.lock file: we can\'t test ' + + 'without dependencies.\nPlease run `bundle install` first.'); + } + + const gemfile = await tryGetSpec(root, path.join(targetDir, 'Gemfile')); + + if (gemfile) { + files.gemfile = gemfile; + } + + return { + packageName: path.basename(root), + targetFile: path.join(targetDir, targetName), + files, + }; +} diff --git a/src/lib/plugins/rubygems/inspectors/gemspec.js b/src/lib/plugins/rubygems/inspectors/gemspec.js deleted file mode 100644 index 303c1bb7fd..0000000000 --- a/src/lib/plugins/rubygems/inspectors/gemspec.js +++ /dev/null @@ -1,38 +0,0 @@ -var path = require('path'); -var tryGetSpec = require('./try-get-spec'); -var pattern = /\.gemspec$/; - -module.exports = { - canHandle: function handles(file) { - return file && pattern.test(file); - }, - - gatherSpecs: function gatherSpecs(root, target) { - var targetName = path.basename(target); - var targetDir = path.dirname(target); - var files = {}; - - var gemspec = tryGetSpec(root, path.join(targetDir, targetName)); - if (gemspec) { - files.gemspec = gemspec; - } else { - throw 'File not found: ' + target; - } - - var gemfileLock = tryGetSpec(root, path.join(targetDir, 'Gemfile.lock')); - if (gemfileLock) { - files.gemfileLock = gemfileLock; - } - - var gemfile = tryGetSpec(root, path.join(targetDir, 'Gemfile')); - if (gemfile) { - files.gemfile = gemfile; - } - - return Promise.resolve({ - packageName: path.basename(root), - targetFile: path.join(targetDir, targetName), - files: files, - }); - }, -}; diff --git a/src/lib/plugins/rubygems/inspectors/gemspec.ts b/src/lib/plugins/rubygems/inspectors/gemspec.ts new file mode 100644 index 0000000000..cb20d61d91 --- /dev/null +++ b/src/lib/plugins/rubygems/inspectors/gemspec.ts @@ -0,0 +1,41 @@ +import * as path from 'path'; +import {Files, tryGetSpec} from './try-get-spec'; +import {Spec} from './index'; + +const pattern = /\.gemspec$/; + +export function canHandle(file: string): boolean { + return !!file && pattern.test(file); +} + +export async function gatherSpecs(root: string, target: string): Promise { + const targetName = path.basename(target); + const targetDir = path.dirname(target); + const files: Files = {}; + + const gemspec = await tryGetSpec(root, path.join(targetDir, targetName)); + + if (gemspec) { + files.gemspec = gemspec; + } else { + throw new Error(`File not found: ${target}`); + } + + const gemfileLock = await tryGetSpec(root, path.join(targetDir, 'Gemfile.lock')); + + if (gemfileLock) { + files.gemfileLock = gemfileLock; + } + + const gemfile = await tryGetSpec(root, path.join(targetDir, 'Gemfile')); + + if (gemfile) { + files.gemfile = gemfile; + } + + return { + packageName: path.basename(root), + targetFile: path.join(targetDir, targetName), + files, + }; +} diff --git a/src/lib/plugins/rubygems/inspectors/index.js b/src/lib/plugins/rubygems/inspectors/index.js deleted file mode 100644 index ed3535db0b..0000000000 --- a/src/lib/plugins/rubygems/inspectors/index.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = [ - require('./gemspec'), - require('./gemfile'), -]; diff --git a/src/lib/plugins/rubygems/inspectors/index.ts b/src/lib/plugins/rubygems/inspectors/index.ts new file mode 100644 index 0000000000..212e19645c --- /dev/null +++ b/src/lib/plugins/rubygems/inspectors/index.ts @@ -0,0 +1,14 @@ +import * as gemfile from './gemfile'; +import * as gemspec from './gemspec'; +import {Files} from './try-get-spec'; + +export interface Spec { + packageName: string; + targetFile: string; + files: Files; +} + +export const inspectors = [ + gemfile, + gemspec, +]; diff --git a/src/lib/plugins/rubygems/inspectors/try-get-spec.js b/src/lib/plugins/rubygems/inspectors/try-get-spec.js deleted file mode 100644 index 6b842b67c8..0000000000 --- a/src/lib/plugins/rubygems/inspectors/try-get-spec.js +++ /dev/null @@ -1,13 +0,0 @@ -var fs = require('then-fs'); -var path = require('path'); - -module.exports = function tryGetSpec(dir, name) { - var file = path.resolve(dir, name); - if (fs.existsSync(file)) { - return { - name: name, - contents: new Buffer(fs.readFileSync(file)).toString('base64'), - }; - } - return null; -}; diff --git a/src/lib/plugins/rubygems/inspectors/try-get-spec.ts b/src/lib/plugins/rubygems/inspectors/try-get-spec.ts new file mode 100644 index 0000000000..c4c3c35dd5 --- /dev/null +++ b/src/lib/plugins/rubygems/inspectors/try-get-spec.ts @@ -0,0 +1,25 @@ +import * as path from 'path'; +import * as fs from 'then-fs'; + +interface File { + name: string; + contents: string; +} + +export interface Files { + gemfileLock?: File; + gemfile?: File; + gemspec?: File; +} + +export async function tryGetSpec(dir: string, name: string): Promise { + const filePath = path.resolve(dir, name); + + if (await fs.exists(filePath)) { + return { + name, + contents: new Buffer(await fs.readFile(filePath)).toString('base64'), + }; + } + return null; +} diff --git a/src/lib/plugins/yarn/index.js b/src/lib/plugins/yarn/index.js deleted file mode 100644 index 7e3853af01..0000000000 --- a/src/lib/plugins/yarn/index.js +++ /dev/null @@ -1,87 +0,0 @@ -const snyk = require('../../'); -const fileSystem = require('fs'); -const fs = require('then-fs'); -const path = require('path'); -const lockFileParser = require('snyk-nodejs-lockfile-parser'); -const debug = require('debug')('snyk'); -const _ = require('lodash'); - -module.exports = { - inspect, -}; - -async function inspect(root, targetFile, options) { - const isLockFileBased = targetFile.endsWith('yarn.lock'); - - const isShrinkwrapPresent = fileSystem.existsSync( - path.resolve(root, targetFile).dir, 'npm-shrinkwrap.json' - ); - - if (getRuntimeVersion() < 6) { - options.traverseNodeModules = true; - - debug('Falling back to node_modules traversal for yarn.lock projects on Node < 6'); - const isNodeModulesFolderPresent = await fs.exists(path.join(root, 'node_modules')); - if (!isNodeModulesFolderPresent) { - // throw a custom error - throw new Error('Missing node_modules folder: we can\'t test ' + - 'without dependencies.\nPlease run \'yarn install\' first.'); - } - } - - if (isLockFileBased && !isShrinkwrapPresent && !options.traverseNodeModules) { - return generateDependenciesFromLockfile(root, options, targetFile) - .then((modules) => ({ - plugin: { - name: 'snyk-nodejs-lockfile-parser', - runtime: process.version, - }, - package: modules, - })); - } - - // traverse node modules - return snyk.modules(root, Object.assign({}, options, {noFromArrays: true})) - .then(function (modules) { - return { - plugin: { - name: 'snyk-resolve-deps', - runtime: process.version, - }, - package: modules, - }; - }); -} - -async function generateDependenciesFromLockfile(root, options, targetFile) { - const lockFileFullPath = path.resolve(root, targetFile); - if (!fileSystem.existsSync(lockFileFullPath)) { - throw new Error('Lockfile ' + targetFile + ' not found at location: ' + - lockFileFullPath); - } - - const fullPath = path.parse(lockFileFullPath); - const manifestFileFullPath = path.resolve(fullPath.dir, 'package.json'); - - if (!fileSystem.existsSync(manifestFileFullPath)) { - throw new Error('Manifest file yarn.lock not found at location: ' + - manifestFileFullPath); - } - - if (!manifestFileFullPath && lockFileFullPath) { - throw new Error('Detected a lockfile at location: ' - + lockFileFullPath + '\n However the yarn.lock is missing!'); - } - - const manifestFile = await fs.readFile(manifestFileFullPath, 'utf-8'); - const lockFile = await fs.readFile(lockFileFullPath, 'utf-8'); - const defaultManifestFileName = path.relative(root, manifestFileFullPath); - - const strictOutOfSync = _.get(options, 'strictOutOfSync', true); - return lockFileParser.buildDepTree(manifestFile, lockFile, options.dev, - lockFileParser.LockfileType.yarn, strictOutOfSync, defaultManifestFileName); -} - -function getRuntimeVersion() { - return parseInt(process.version.slice(1).split('.')[0], 10); -} diff --git a/src/lib/plugins/yarn/index.ts b/src/lib/plugins/yarn/index.ts new file mode 100644 index 0000000000..58f0505791 --- /dev/null +++ b/src/lib/plugins/yarn/index.ts @@ -0,0 +1,98 @@ +import * as path from 'path'; +import * as fs from 'then-fs'; +import * as _ from 'lodash'; +import * as Debug from 'debug'; +import {buildDepTree, PkgTree, LockfileType} from 'snyk-nodejs-lockfile-parser'; +import * as snyk from '../../'; + +const debug = Debug('snyk'); + +interface Options { + traverseNodeModules?: boolean; + dev?: boolean; + strictOutOfSync?: boolean; +} + +interface InspectResult { + plugin: { + name: string; + runtime: string; + }; + package: PkgTree; +} + +export async function inspect(root, targetFile, options: Options = {}): Promise { + const isLockFileBased = targetFile.endsWith('yarn.lock'); + const targetFileFullPath = path.resolve(root, targetFile); + const isShrinkwrapPresent = await fs.exists(path.join(path.dirname(targetFileFullPath), 'npm-shrinkwrap.json')); + + if (getRuntimeVersion() < 6) { + options.traverseNodeModules = true; + + debug('Falling back to node_modules traversal for yarn.lock projects on Node < 6'); + const isNodeModulesFolderPresent = await fs.exists(path.join(root, 'node_modules')); + if (!isNodeModulesFolderPresent) { + // throw a custom error + throw new Error('Missing node_modules folder: we can\'t test ' + + 'without dependencies.\nPlease run \'yarn install\' first.'); + } + } + + if (isLockFileBased && !isShrinkwrapPresent && !options.traverseNodeModules) { + return { + plugin: { + name: 'snyk-nodejs-lockfile-parser', + runtime: process.version, + }, + package: await generateDependenciesFromLockfile(root, options, targetFile), + }; + } + + // Traverse node modules. + return { + plugin: { + name: 'snyk-resolve-deps', + runtime: process.version, + }, + package: await snyk.modules(root, Object.assign({}, options, {noFromArrays: true})), + }; +} + +function getRuntimeVersion(): number { + return parseInt(process.version.slice(1).split('.')[0], 10); +} + +async function generateDependenciesFromLockfile(root, options, targetFile): Promise { + const lockFileFullPath = path.resolve(root, targetFile); + if (!await fs.exists(lockFileFullPath)) { + throw new Error(`Lockfile ${targetFile} not found at location: ${lockFileFullPath}`); + } + + const fullPath = path.parse(lockFileFullPath); + const manifestFileFullPath = path.resolve(fullPath.dir, 'package.json'); + + if (!await fs.exists(manifestFileFullPath)) { + throw new Error(`Manifest file yarn.lock not found at location: ${manifestFileFullPath}`); + } + + if (!manifestFileFullPath && lockFileFullPath) { + throw new Error(`Detected a lockfile at location: ${lockFileFullPath}\nHowever the yarn.lock is missing!`); + } + + const [manifestFile, lockFile] = await Promise.all([ + await fs.readFile(manifestFileFullPath, 'utf-8'), + await fs.readFile(lockFileFullPath, 'utf-8'), + ]); + + const defaultManifestFileName = path.relative(root, manifestFileFullPath); + const strictOutOfSync = _.get(options, 'strictOutOfSync', true); + + return buildDepTree( + manifestFile, + lockFile, + options.dev, + LockfileType.yarn, + strictOutOfSync, + defaultManifestFileName, + ); +} diff --git a/test/acceptance/cli.acceptance.test.ts b/test/acceptance/cli.acceptance.test.ts index 3f136c29ff..24f36c1b6e 100644 --- a/test/acceptance/cli.acceptance.test.ts +++ b/test/acceptance/cli.acceptance.test.ts @@ -7,7 +7,6 @@ import * as _ from 'lodash'; import * as cli from '../../src/cli/commands'; import * as fakeServer from './fake-server'; import * as subProcess from '../../src/lib/sub-process'; -import * as plugins from '../../src/lib/plugins'; import * as needle from 'needle'; // ensure this is required *after* the demo server, since this will @@ -31,6 +30,9 @@ const server: any = fakeServer(process.env.SNYK_API, apiKey); const before = tap.runOnly ? only : test; const after = tap.runOnly ? only : test; +// Should be after `process.env` setup. +import * as plugins from '../../src/lib/plugins'; + // @later: remove this config stuff. // Was copied straight from ../src/cli-server.js before('setup', async (t) => {