mirror of
				https://github.com/actions/setup-dotnet.git
				synced 2025-10-31 16:13:46 +00:00 
			
		
		
		
	Make assigning of the script path intuitive
This commit is contained in:
		
							parent
							
								
									427804d76a
								
							
						
					
					
						commit
						820f30d332
					
				
							
								
								
									
										23
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										23
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							| @ -341,13 +341,14 @@ class DotnetInstallScript { | ||||
|     constructor() { | ||||
|         this.scriptName = utils_1.IS_WINDOWS ? 'install-dotnet.ps1' : 'install-dotnet.sh'; | ||||
|         this.scriptArguments = []; | ||||
|         this.scriptPath = ''; | ||||
|         this.escapedScript = path_1.default | ||||
|             .join(__dirname, '..', 'externals', this.scriptName) | ||||
|             .replace(/'/g, "''"); | ||||
|         this.scriptReady = utils_1.IS_WINDOWS | ||||
|             ? this.setupScriptPowershell() | ||||
|             : this.setupScriptBash(); | ||||
|         if (utils_1.IS_WINDOWS) { | ||||
|             this.setupScriptPowershell(); | ||||
|             return; | ||||
|         } | ||||
|         this.setupScriptBash(); | ||||
|     } | ||||
|     setupScriptPowershell() { | ||||
|         return __awaiter(this, void 0, void 0, function* () { | ||||
| @ -368,14 +369,19 @@ class DotnetInstallScript { | ||||
|             if (process.env['no_proxy'] != null) { | ||||
|                 this.scriptArguments.push(`-ProxyBypassList ${process.env['no_proxy']}`); | ||||
|             } | ||||
|             this.scriptPath = | ||||
|                 (yield io.which('pwsh', false)) || (yield io.which('powershell', true)); | ||||
|         }); | ||||
|     } | ||||
|     setupScriptBash() { | ||||
|         return __awaiter(this, void 0, void 0, function* () { | ||||
|             (0, fs_1.chmodSync)(this.escapedScript, '777'); | ||||
|             this.scriptPath = yield io.which(this.escapedScript, true); | ||||
|         }); | ||||
|     } | ||||
|     getScriptPath() { | ||||
|         return __awaiter(this, void 0, void 0, function* () { | ||||
|             if (utils_1.IS_WINDOWS) { | ||||
|                 return (yield io.which('pwsh', false)) || io.which('powershell', true); | ||||
|             } | ||||
|             return io.which(this.escapedScript, true); | ||||
|         }); | ||||
|     } | ||||
|     useArguments(...args) { | ||||
| @ -401,8 +407,7 @@ class DotnetInstallScript { | ||||
|                 ignoreReturnCode: true, | ||||
|                 env: process.env | ||||
|             }; | ||||
|             yield this.scriptReady; | ||||
|             return exec.getExecOutput(`"${this.scriptPath}"`, this.scriptArguments, getExecOutputOptions); | ||||
|             return exec.getExecOutput(`"${yield this.getScriptPath()}"`, this.scriptArguments, getExecOutputOptions); | ||||
|         }); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -129,17 +129,18 @@ export class DotnetInstallScript { | ||||
|   private scriptName = IS_WINDOWS ? 'install-dotnet.ps1' : 'install-dotnet.sh'; | ||||
|   private escapedScript: string; | ||||
|   private scriptArguments: string[] = []; | ||||
|   private scriptPath = ''; | ||||
|   private scriptReady: Promise<void>; | ||||
| 
 | ||||
|   constructor() { | ||||
|     this.escapedScript = path | ||||
|       .join(__dirname, '..', 'externals', this.scriptName) | ||||
|       .replace(/'/g, "''"); | ||||
| 
 | ||||
|     this.scriptReady = IS_WINDOWS | ||||
|       ? this.setupScriptPowershell() | ||||
|       : this.setupScriptBash(); | ||||
|     if (IS_WINDOWS) { | ||||
|       this.setupScriptPowershell(); | ||||
|       return; | ||||
|     } | ||||
| 
 | ||||
|     this.setupScriptBash(); | ||||
|   } | ||||
| 
 | ||||
|   private async setupScriptPowershell() { | ||||
| @ -162,14 +163,18 @@ export class DotnetInstallScript { | ||||
|     if (process.env['no_proxy'] != null) { | ||||
|       this.scriptArguments.push(`-ProxyBypassList ${process.env['no_proxy']}`); | ||||
|     } | ||||
| 
 | ||||
|     this.scriptPath = | ||||
|       (await io.which('pwsh', false)) || (await io.which('powershell', true)); | ||||
|   } | ||||
| 
 | ||||
|   private async setupScriptBash() { | ||||
|     chmodSync(this.escapedScript, '777'); | ||||
|     this.scriptPath = await io.which(this.escapedScript, true); | ||||
|   } | ||||
| 
 | ||||
|   private async getScriptPath() { | ||||
|     if (IS_WINDOWS) { | ||||
|       return (await io.which('pwsh', false)) || io.which('powershell', true); | ||||
|     } | ||||
| 
 | ||||
|     return io.which(this.escapedScript, true); | ||||
|   } | ||||
| 
 | ||||
|   public useArguments(...args: string[]) { | ||||
| @ -202,10 +207,8 @@ export class DotnetInstallScript { | ||||
|       env: process.env as {string: string} | ||||
|     }; | ||||
| 
 | ||||
|     await this.scriptReady; | ||||
| 
 | ||||
|     return exec.getExecOutput( | ||||
|       `"${this.scriptPath}"`, | ||||
|       `"${await this.getScriptPath()}"`, | ||||
|       this.scriptArguments, | ||||
|       getExecOutputOptions | ||||
|     ); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user