const fs = require ( 'fs' ) ; const path = require ( 'path' ) ; let useCustomEnvPath = false ; if ( process . env . ENV_CONFIG_PATH ) { let envFilePath = process . env . ENV_CONFIG_PATH ; if ( ! path . isAbsolute ( process . env . ENV_CONFIG_PATH ) ) { envFilePath = path . resolve ( process . cwd ( ) , envFilePath ) ; } if ( fs . existsSync ( envFilePath ) ) { useCustomEnvPath = true ; require ( 'dotenv' ) . config ( { path : envFilePath , } ) ; } } if ( ! useCustomEnvPath ) { require ( 'dotenv' ) . config ( ) ; } const { getDefault } = require ( './src/globals' ) ; const { resolveExtensions } = getDefault ( require ( './src/extensions' ) ) ; desc type { boolean } let cacheEnabled = true ; /**
 * Traverse through all the arguments and check if the user has
 * indicated if he does not want to use cache!
 */ Array . from ( process . argv ) . forEach ( ( arg ) => { const lArg = arg . toLowerCase ( ) ; if ( lArg . indexOf ( '-nc' ) !== false || lArg . indexOf ( '--no-cache' ) !== false ) { process . env . BABEL_DISABLE_CACHE = 1 ; cacheEnabled = false ; } } ) ; const babelServerOptions = getDefault ( require ( './src/babel/node.js' ) ) ( { cacheDirectory : cacheEnabled , hot : false , noChunk : true , cache : cacheEnabled , } ) . use . options ; /**
 * Use babel register so that we can use latest EcmaScript & TypeScript version
 * in included files. Also we need to make sure that any plugins for pawjs or pawjs core
 * modules needs to be access with new code directly and there should be no need for
 * compiled code even if it lies in node_modules
 */ require ( '@babel/register' ) ( { presets : babelServerOptions . presets , plugins : babelServerOptions . plugins , cache : cacheEnabled , ignore : [ /node_modules\/(?!(@pawjs|pawjs-)).*/ , ] , extensions : resolveExtensions , } ) ; /**
 * After registering babel we can include typescript (TS) files as well
 */ const CliHandler = getDefault ( require ( './src/scripts/cli.ts' ) ) ; const handler = new CliHandler ( ) ; handler . run ( ) ; module . exports = handler ;