How to use the dependency-check.extra function in dependency-check

To help you get started, we’ve selected a few dependency-check 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 ghaiklor / generator-sails-rest-api / generators / app / templates / tools / check-deps.js View on Github external
}, function (error, data) {
    if (error) {
      console.error(error.stack || error);
      return process.exit(1);
    }

    var pkg = data.package;
    var dependencies = data.used;
    var unusedDependencies = checkDependencies.extra(pkg, dependencies, {excludeDev: true});
    var missingDependencies = checkDependencies.missing(pkg, dependencies);

    if (unusedDependencies.length === 0 && missingDependencies.length === 0) {
      printMessage([
        "Checking dependencies successfully done",
        "---",
        "Unused dependencies - " + "Not Found",
        "Missing dependencies - " + "Not Found"
      ], {
        borderColor: 'green',
        marginTop: 0,
        marginBottom: 0
      });

      process.exit(0);
    }
github JamesKyburz / install-missing / index.js View on Github external
function missing (err, installed) {
    if (err) {
      log.error(err)
      return cb(err)
    }
    var pending = 2
    install(dependencyCheck.missing(installed.package, installed.used), done)
    uninstall(dependencyCheck.extra(installed.package, installed.used, { excludeDev: true }), done)

    function done (err) {
      if (err) {
        return cb(err)
      } else {
        pending--
        if (!pending) cb(err)
      }
    }
  }
github bloglovin / lintlovin / tasks / dependency-check.js View on Github external
check({ path: options.package, entries: this.filesSrc }, function(err, data) {
      if (err) {
        return grunt.fail.fatal(err);
      }

      var pkg = data.package;
      var deps = data.used;
      var results;

      if (options.unused) {
        results = check.extra(pkg, deps, { excludeDev: options.excludeMissingDev });
        if (results.length !== 0) {
          grunt.log.error('Modules in package.json not used in code: ' + grunt.log.wordlist(results, { color: 'red' }));
        }
      }

      if (options.missing) {
        results = check.missing(pkg, deps);
        if (results.length !== 0) {
          grunt.fail.fatal('Dependencies not listed in package.json: ' + grunt.log.wordlist(results, { color: 'red' }));
        }
      }

      done();
    });
  });

dependency-check

checks which modules you have used in your code and then makes sure they are listed as dependencies in your package.json

BSD-3-Clause
Latest version published 5 years ago

Package Health Score

47 / 100
Full package analysis

Popular dependency-check functions