import * as program from 'commander' ; import { fileExists , folderExists } from './filesys' ; import { makeVetPaths , getCLIOptions } from './cliopts' ; import vet from './vet' ; import { getRenderer } from './renderers/index' ; const vetPkgFile = require ( '../package.json' ) ; program . version ( vetPkgFile . version ) . option ( '-p, --package <package>' , 'package.json file location' , '' ) . option ( '-m, --modules <modules>' , 'node_modules folder location' , '' ) . option ( '-r, --renderer <renderer>' , 'Renderer to use' , 'inlinetable' ) . option ( '-s, --strict' , 'Using the CI renderer, fail build if any packages unlocked' ) ; const opts = getCLIOptions ( program . parse ( process . argv ) ) ; const paths = makeVetPaths ( opts ) ; if ( ! fileExists ( paths . packagePath ) ) { throw new Error ( `Cannot find package.json file at ${ paths . packagePath }` ) ; } if ( ! folderExists ( paths . modulesPath ) ) { throw new Error ( `Cannot find node_modules file at ${ paths . packagePath }` ) ; } let renderer = getRenderer ( opts . renderer ) ; const packageFile = require ( paths . packagePath ) ; let map = vet ( packageFile , paths . modulesPath ) ; renderer ( map , opts ) ;