UNPKG

@kudobuzz/kbscripts

Version:

Configuration and scripts for kudobuzz projects

43 lines (34 loc) 1.03 kB
'use strict' const spawn = require('cross-spawn') const yargs = require('yargs-parser') const { getPathToGlobalCommand, hereRelative, resolveExecutable } = require('../common/utils') let args = process.argv.slice(2) const parsedAgs = yargs(args) const executable = 'eslint' const customIgnorePath = parsedAgs['ignore-path'] if (customIgnorePath) { args = args.filter((arg) => !arg.startsWith('--ignore-path')) } const wasGivenFiles = parsedAgs._.length > 0 const filesToApply = wasGivenFiles ? [] : ['.'] args = wasGivenFiles ? args : args const config = ['--config', hereRelative('../config/eslintrc.js')] const ignore = [ '--ignore-path', customIgnorePath || hereRelative('../config/eslintignore') ] const resolveParams = { pathToGlobalCommand: getPathToGlobalCommand(executable), moduleName: executable, cwd: process.cwd() } const result = spawn.sync( resolveExecutable(executable, resolveParams), [...config, ...ignore, ...args, ...filesToApply], { stdio: 'inherit' } ) process.exit(result.status)