All files / check-installed/lib cli.js

100% Statements 15/15
100% Branches 7/7
100% Functions 1/1
100% Lines 15/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 332x 2x 2x 2x 2x               4x 4x   4x 1x 1x     3x 2x     3x 2x       2x      
const { resolve } = require('path')
const { HELP } = require('./constants')
const { getOptions } = require('./getOptions')
const { checkEngines } = require('./checkEngines')
const { checkModules } = require('./checkModules')
 
/**
 * check-installed CLI entry point
 * @param {string[]} argv - CLI arguments
 * @returns {Promise<void>} - Promise that resolves when the CLI is done (throws on check fail)
 */
async function cli (argv = process.argv) {
  const json = require(resolve(process.cwd(), 'package.json'))
  const options = getOptions(argv.slice(2))
 
  if (options.help) {
    console.log(HELP)
    return
  }
 
  if (!options.skipEngines) {
    await checkEngines(json, options)
  }
 
  if (!options.skipModules) {
    await checkModules(json, options)
  }
}
 
module.exports = {
  cli
}