| 
									
										
										
										
											2021-12-26 00:32:00 +00:00
										 |  |  | import { exec } from 'child_process'; | 
					
						
							| 
									
										
										
										
											2021-12-25 20:05:17 +00:00
										 |  |  | import CloudRunnerLogger from '../../cloud-runner/services/cloud-runner-logger'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export class RemoteClientSystem { | 
					
						
							|  |  |  |   public static async Run(command: string) { | 
					
						
							| 
									
										
										
										
											2021-12-26 00:32:00 +00:00
										 |  |  |     return await new Promise<string>((promise) => { | 
					
						
							|  |  |  |       exec(command, (error, stdout, stderr) => { | 
					
						
							|  |  |  |         if (error) { | 
					
						
							|  |  |  |           CloudRunnerLogger.logRemoteCli(`[ERROR] ${error.message}`); | 
					
						
							|  |  |  |           throw new Error(error.toString()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if (stderr) { | 
					
						
							|  |  |  |           CloudRunnerLogger.logRemoteCli(`[STD-ERROR] ${stderr.toString()}`); | 
					
						
							|  |  |  |           throw new Error(stderr.toString()); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         CloudRunnerLogger.logRemoteCli(`${stdout.toString()}`); | 
					
						
							|  |  |  |         promise(stdout.toString()); | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2021-12-25 20:05:17 +00:00
										 |  |  |   } | 
					
						
							|  |  |  | } |