mirror of
				https://github.com/docker/setup-qemu-action.git
				synced 2025-10-31 01:00:11 +08:00 
			
		
		
		
	Use built-in getExecOutput
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									aa087459ac
								
							
						
					
					
						commit
						c47ad32952
					
				
							
								
								
									
										2
									
								
								dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								dist/index.js
									
									
									
										generated
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										2
									
								
								dist/index.js.map
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								dist/index.js.map
									
									
									
										generated
									
									
										vendored
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										34
									
								
								src/exec.ts
									
									
									
									
									
								
							
							
						
						
									
										34
									
								
								src/exec.ts
									
									
									
									
									
								
							| @ -1,34 +0,0 @@ | |||||||
| import * as actionsExec from '@actions/exec'; |  | ||||||
| import {ExecOptions} from '@actions/exec'; |  | ||||||
| 
 |  | ||||||
| export interface ExecResult { |  | ||||||
|   success: boolean; |  | ||||||
|   stdout: string; |  | ||||||
|   stderr: string; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| export const exec = async (command: string, args: string[] = [], silent: boolean): Promise<ExecResult> => { |  | ||||||
|   let stdout = ''; |  | ||||||
|   let stderr = ''; |  | ||||||
| 
 |  | ||||||
|   const options: ExecOptions = { |  | ||||||
|     silent: silent, |  | ||||||
|     ignoreReturnCode: true |  | ||||||
|   }; |  | ||||||
|   options.listeners = { |  | ||||||
|     stdout: (data: Buffer) => { |  | ||||||
|       stdout += data.toString(); |  | ||||||
|     }, |  | ||||||
|     stderr: (data: Buffer) => { |  | ||||||
|       stderr += data.toString(); |  | ||||||
|     } |  | ||||||
|   }; |  | ||||||
| 
 |  | ||||||
|   const returnCode: number = await actionsExec.exec(command, args, options); |  | ||||||
| 
 |  | ||||||
|   return { |  | ||||||
|     success: returnCode === 0, |  | ||||||
|     stdout: stdout.trim(), |  | ||||||
|     stderr: stderr.trim() |  | ||||||
|   }; |  | ||||||
| }; |  | ||||||
							
								
								
									
										22
									
								
								src/main.ts
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								src/main.ts
									
									
									
									
									
								
							| @ -1,4 +1,3 @@ | |||||||
| import * as mexec from './exec'; |  | ||||||
| import * as core from '@actions/core'; | import * as core from '@actions/core'; | ||||||
| import * as exec from '@actions/exec'; | import * as exec from '@actions/exec'; | ||||||
| import {issueCommand} from '@actions/core/lib/command'; | import {issueCommand} from '@actions/core/lib/command'; | ||||||
| @ -31,14 +30,19 @@ async function run(): Promise<void> { | |||||||
|     core.endGroup(); |     core.endGroup(); | ||||||
| 
 | 
 | ||||||
|     core.startGroup(`Extracting available platforms`); |     core.startGroup(`Extracting available platforms`); | ||||||
|     await mexec.exec(`docker`, ['run', '--rm', '--privileged', image], true).then(res => { |     await exec | ||||||
|       if (res.stderr != '' && !res.success) { |       .getExecOutput('docker', ['run', '--rm', '--privileged', image], { | ||||||
|         throw new Error(res.stderr); |         ignoreReturnCode: true, | ||||||
|       } |         silent: true | ||||||
|       const platforms: Platforms = JSON.parse(res.stdout.trim()); |       }) | ||||||
|       core.info(`${platforms.supported.join(',')}`); |       .then(res => { | ||||||
|       setOutput('platforms', platforms.supported.join(',')); |         if (res.stderr.length > 0 && res.exitCode != 0) { | ||||||
|     }); |           throw new Error(res.stderr.trim()); | ||||||
|  |         } | ||||||
|  |         const platforms: Platforms = JSON.parse(res.stdout.trim()); | ||||||
|  |         core.info(`${platforms.supported.join(',')}`); | ||||||
|  |         setOutput('platforms', platforms.supported.join(',')); | ||||||
|  |       }); | ||||||
|     core.endGroup(); |     core.endGroup(); | ||||||
|   } catch (error) { |   } catch (error) { | ||||||
|     core.setFailed(error.message); |     core.setFailed(error.message); | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 CrazyMax
						CrazyMax