UNPKG

@interaktiv/dia-scripts

Version:

CLI toolbox with common scripts for most sort of projects at DIA

34 lines (26 loc) 969 B
"use strict"; const path = require('path'); const exit = require('exit'); const spawn = require('cross-spawn'); const { isOptedOut, hasPkgProp, hasFile, resolveBin } = require('../utils'); (function () { const here = p => path.join(__dirname, p); const args = process.argv.slice(2); const useBuiltInConfig = args.includes('--config') !== true && hasFile('.lintstagedrc') !== true && hasFile('lint-staged.config.js') !== true && hasPkgProp('lint-staged') !== true; const config = useBuiltInConfig ? ['--config', (p => here(p).replace(process.cwd(), '.'))('../config/lintstagedrc.js')] : []; const lintStagedResult = spawn.sync(resolveBin('lint-staged'), [...config, ...args], { stdio: 'inherit' }); if (lintStagedResult.status !== 0 || isOptedOut('pre-commit')) { exit(lintStagedResult.status); } const validationResult = spawn.sync('npm', ['run', 'validate'], { stdio: 'inherit' }); exit(validationResult.status); })();