UNPKG

1.02 kBJavaScriptView Raw
1'use strict'
2
3const execa = require('execa')
4const path = require('path')
5const { fromAegir, fromRoot } = require('../src/utils')
6
7const EPILOG = `
8Supports options forwarding with '--' for more info check https://github.com/tclindner/npm-package-json-lint#cli-commands-and-configuration
9`
10
11module.exports = {
12 command: 'lint-package-json',
13 desc: 'Lint package.json with aegir defaults.',
14 aliases: ['lint-package', 'lpj'],
15 builder: (yargs) => {
16 yargs
17 .epilog(EPILOG)
18 },
19 handler (argv) {
20 const input = argv._.slice(1)
21 const forwardOptions = argv['--'] ? argv['--'] : []
22 const useBuiltinConfig = !forwardOptions.includes('--configFile')
23 const config = useBuiltinConfig
24 ? ['-c', fromAegir('src/config/.npmpackagejsonlintrc.json')]
25 : []
26
27 return execa('npmPkgJsonLint', [
28 fromRoot('package.json'),
29 ...config,
30 ...input,
31 ...forwardOptions
32 ], {
33 stdio: 'inherit',
34 localDir: path.join(__dirname, '..'),
35 preferLocal: true
36 })
37 }
38}