import child = require ( "promisify-child-process" ) ; import { SpawnOptions } from "child_process" ; import { resolve } from "path" ; export class OradewProcess { wsConfigPath : string ; gulpPathJs : string ; gulpFile : string ; gulpParams : Array < string > ; processEnv : SpawnOptions ; cliPath : string ; constructor ( tmConfig ) { const { workspaceDir , cliDir , storageDir , wsConfigPath , dbConfigPath , isSilent , isColor , cliExecutable , cliCommand , envVariables , } = tmConfig ; this . gulpPathJs = resolve ( cliDir , "node_modules/gulp/bin/gulp.js" ) ; this . gulpFile = resolve ( cliDir , "dist/gulpfile.js" ) ; this . cliPath = resolve ( cliDir , "dist/oradew.js" ) ; this . gulpParams = [ `${ this . gulpPathJs }` , "--cwd" , `${ workspaceDir }` , "--gulpfile" , `${ this . gulpFile }` , ... ( isColor ? [ "--color" , "true" ] : [ ] ) , ... ( isSilent ? [ "--silent" , "true" ] : [ ] ) , ] ; this . processEnv = { env : { ... process . env , NODE_OPTIONS : "--no-deprecation" , ORADEW_STORAGE_DIR : storageDir , ORADEW_DB_CONFIG_PATH : dbConfigPath , ORADEW_WS_CONFIG_PATH : wsConfigPath , ORADEW_CLI_EXECUTABLE : cliExecutable , ORADEW_CLI_COMMAND : cliCommand , ORADEW_SILENT : isSilent . toString ( ) , ... ( envVariables || { } ) , } , stdio : "inherit" , } ; } execute = async ( argv ) => { const params = [ ... this . gulpParams , ... argv . slice ( 2 ) ] ; await child . spawn ( process . execPath , params , this . processEnv ) ; } ; }