How to use the snyk-nodejs-lockfile-parser.buildDepTree function in snyk-nodejs-lockfile-parser

To help you get started, we’ve selected a few snyk-nodejs-lockfile-parser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github snyk / snyk / src / lib / snyk-test / npm / index.js View on Github external
.then(() => {
      const strictOutOfSync = _.get(options, 'strictOutOfSync') !== 'false';

      return lockFileParser
        .buildDepTree(manifestFile, lockFile, options.dev, lockFileType, strictOutOfSync);
    })
    // clear spinner in case of success or failure
github snyk / snyk / src / lib / plugins / npm / index.js View on Github external
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);
}
github snyk / snyk / src / lib / plugins / yarn / index.ts View on Github external
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') !== 'false';

  return buildDepTree(
    manifestFile,
    lockFile,
    options.dev,
    LockfileType.yarn,
    strictOutOfSync,
    defaultManifestFileName,
  );
}
github snyk / snyk / src / lib / plugins / npm / index.ts View on Github external
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') !== 'false';

  return await buildDepTree(
    manifestFile,
    lockFile,
    options.dev,
    LockfileType.npm,
    strictOutOfSync,
    defaultManifestFileName,
  );
}
github snyk / snyk / src / lib / plugins / yarn / index.js View on Github external
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);
}
github snyk / snyk / src / lib / plugins / nodejs-plugin / npm-lock-parser.ts View on Github external
analytics.add('local', true);
  analytics.add('generating-node-dependency-tree', {
    lockFile: true,
    targetFile,
  });

  const lockFileType = targetFile.endsWith('yarn.lock')
    ? lockFileParser.LockfileType.yarn
    : lockFileParser.LockfileType.npm;

  const resolveModuleSpinnerLabel = `Analyzing npm dependencies for ${lockFileFullPath}`;
  debug(resolveModuleSpinnerLabel);
  try {
    await spinner(resolveModuleSpinnerLabel);
    const strictOutOfSync = options.strictOutOfSync !== false;
    return lockFileParser.buildDepTree(
      manifestFile,
      lockFile,
      options.dev,
      lockFileType,
      strictOutOfSync,
    );
  } finally {
    await spinner.clear(resolveModuleSpinnerLabel);
  }
}

snyk-nodejs-lockfile-parser

Generate a dep tree given a lockfile

Apache-2.0
Latest version published 1 month ago

Package Health Score

74 / 100
Full package analysis

Similar packages