UNPKG

939 BJavaScriptView Raw
1'use strict'
2
3const path = require('path')
4const execa = require('execa')
5const merge = require('merge-options')
6
7/** @typedef { import("execa").Options} ExecaOptions */
8/** @typedef { import("execa").ExecaChildProcess} ExecaChildProcess */
9
10const defaultInput = [
11 'package.json',
12 './test/**/*.js',
13 './src/**/*.js',
14 '!./test/fixtures/**/*.js'
15]
16
17/**
18 * Check dependencies
19 *
20 * @param {Object} argv
21 * @param {ExecaOptions} execaOptions
22 * @returns {ExecaChildProcess}
23 */
24const check = (argv = { _: [] }, execaOptions) => {
25 const input = argv._.slice(1)
26 const forwardOptions = argv['--'] ? argv['--'] : []
27 const defaults = input.length ? input : defaultInput
28 return execa('dependency-check',
29 [
30 ...defaults,
31 '--missing',
32 ...forwardOptions
33 ],
34 merge(
35 {
36 localDir: path.join(__dirname, '..'),
37 preferLocal: true
38 },
39 execaOptions
40 )
41 )
42}
43
44module.exports = check