How to use snyk-nodejs-lockfile-parser - 10 common examples

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 / snyk-test / npm / index.js View on Github external
if (fileSystem.existsSync(shrinkwrapFullPath)) {
    throw new Error('`npm-shrinkwrap.json` was found while using lockfile.\n'
    + 'Please run your command again without `--file=' + targetFile + '` flag.');
  }

  const manifestFile = fileSystem.readFileSync(manifestFileFullPath);
  const lockFile = fileSystem.readFileSync(lockFileFullPath, 'utf-8');

  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);
  return spinner(resolveModuleSpinnerLabel)
    .then(() => {
      const strictOutOfSync = _.get(options, 'strictOutOfSync') !== 'false';

      return lockFileParser
        .buildDepTree(manifestFile, lockFile, options.dev, lockFileType, strictOutOfSync);
    })
    // clear spinner in case of success or failure
    .then(spinner.clear(resolveModuleSpinnerLabel))
    .catch((error) => {
      spinner.clear(resolveModuleSpinnerLabel)();
      throw error;
    });
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);
  }
}
github snyk / snyk / src / lib / plugins / yarn / index.js 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 + '\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
'` flag.',
    );
  }

  const manifestFile = fs.readFileSync(manifestFileFullPath, 'utf-8');
  const lockFile = fs.readFileSync(lockFileFullPath, 'utf-8');

  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);
  }
github snyk / snyk / src / lib / plugins / npm / index.js 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 + '\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);
}

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