@@ -8,20 +8,22 @@ const {nanomemoize} = require('nano-memoize');
88const tryCatch = require ( 'try-catch' ) ;
99const wraptile = require ( 'wraptile' ) ;
1010const fullstore = require ( 'fullstore' ) ;
11+ const _cliStaged = require ( '@putout/cli-staged' ) ;
1112
1213const {
1314 getFilePatterns,
1415 getProcessorRunners,
1516 defaultProcessors,
1617} = require ( '@putout/engine-processor' ) ;
1718
19+ const _initReport = require ( '@putout/engine-reporter/report' ) ;
1820const { keypress : _keypress } = require ( '@putout/cli-keypress' ) ;
1921
2022const supportedFiles = require ( './supported-files' ) ;
21- const getOptions = require ( './get-options' ) ;
23+ const _getOptions = require ( './get-options' ) ;
2224const { argvConfig, parseArgs} = require ( './parse-args' ) ;
2325
24- const getFiles = require ( './get-files' ) ;
26+ const { getFiles : _getFiles } = require ( './get-files.mjs ' ) ;
2527const { version, dependencies} = require ( '../../package.json' ) ;
2628const { formatter : defaultFormatter } = require ( '../../putout.json' ) ;
2729const { simpleImport} = require ( './simple-import' ) ;
@@ -46,11 +48,12 @@ const {
4648const noop = ( ) => { } ;
4749const { keys} = Object ;
4850const { isSupported} = supportedFiles ;
49- const getFormatter = nanomemoize ( require ( '@putout/engine-reporter/formatter' ) . getFormatter ) ;
51+ const _getFormatter = nanomemoize ( require ( '@putout/engine-reporter/formatter' ) . getFormatter ) ;
5052
5153const cwd = process . cwd ( ) ;
52- const { PUTOUT_FILES = '' } = process . env ;
53- const envNames = ! PUTOUT_FILES ? [ ] : PUTOUT_FILES . split ( ',' ) ;
54+ const { env} = process ;
55+
56+ const getEnvNames = ( ) => ! env . PUTOUT_FILES ? [ ] : env . PUTOUT_FILES . split ( ',' ) ;
5457
5558const getExitCode = ( wasStop ) => wasStop ( ) ? WAS_STOP : OK ;
5659const isStr = ( a ) => typeof a === 'string' ;
@@ -76,6 +79,13 @@ module.exports = async (overrides = {}) => {
7679 writeFile,
7780 trace = noop ,
7881 keypress = _keypress ,
82+ getOptions = _getOptions ,
83+ getFiles = _getFiles ,
84+ cliStaged = _cliStaged ,
85+ cliCache,
86+ initProcessFile,
87+ initReport = _initReport ,
88+ getFormatter = _getFormatter ,
7989 } = overrides ;
8090
8191 const isStop = parseIsStop ( overrides . isStop || noop , {
@@ -212,7 +222,7 @@ module.exports = async (overrides = {}) => {
212222 const stagedNames = [ ] ;
213223
214224 if ( staged ) {
215- const { get} = require ( '@putout/cli-staged' ) ;
225+ const { get} = cliStaged ;
216226 const { findUp} = await simpleImport ( 'find-up' ) ;
217227
218228 const [ error , names ] = await tryToCatch ( get , {
@@ -229,7 +239,7 @@ module.exports = async (overrides = {}) => {
229239 const globFiles = [
230240 ...stagedNames ,
231241 ...args . _ . map ( String ) ,
232- ...envNames ,
242+ ...getEnvNames ( ) ,
233243 ] ;
234244
235245 const [ e , names ] = await getFiles ( globFiles , {
@@ -247,7 +257,7 @@ module.exports = async (overrides = {}) => {
247257 if ( noFiles )
248258 return exit ( ) ;
249259
250- const { createCache} = await simpleImport ( '@putout/cli-cache' ) ;
260+ const { createCache} = cliCache || await simpleImport ( '@putout/cli-cache' ) ;
251261
252262 const fileCache = await createCache ( {
253263 version,
@@ -273,7 +283,10 @@ module.exports = async (overrides = {}) => {
273283 plugins,
274284 } ;
275285
286+ const report = initReport ( ) ;
287+
276288 const { places, exited} = await run ( {
289+ report,
277290 processorRunners,
278291 trace,
279292 fix,
@@ -294,6 +307,7 @@ module.exports = async (overrides = {}) => {
294307 noConfig,
295308 plugins,
296309 transform,
310+ initProcessFile,
297311 } ) ;
298312
299313 if ( exited )
@@ -313,7 +327,7 @@ module.exports = async (overrides = {}) => {
313327 }
314328
315329 if ( fix && staged ) {
316- const { set} = require ( '@putout/cli-staged' ) ;
330+ const { set} = cliStaged ;
317331 const { findUp} = await simpleImport ( 'find-up' ) ;
318332
319333 const stagedNames = await set ( {
0 commit comments