mirror of
				https://github.com/actions/setup-dotnet.git
				synced 2025-11-04 04:43:47 +00:00 
			
		
		
		
	Fix review point
This commit is contained in:
		
							parent
							
								
									7c495956c6
								
							
						
					
					
						commit
						48c496df53
					
				
							
								
								
									
										29
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										29
									
								
								dist/index.js
									
									
									
									
										vendored
									
									
								
							@ -208,7 +208,7 @@ exports.DotnetQualityValidator = DotnetQualityValidator;
 | 
				
			|||||||
class DotnetVersionResolver {
 | 
					class DotnetVersionResolver {
 | 
				
			||||||
    constructor(version) {
 | 
					    constructor(version) {
 | 
				
			||||||
        this.inputVersion = version.trim();
 | 
					        this.inputVersion = version.trim();
 | 
				
			||||||
        this.resolvedArgument = { type: '', value: '' };
 | 
					        this.resolvedArgument = { type: '', value: '', qualityFlag: false };
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    resolveVersionInput() {
 | 
					    resolveVersionInput() {
 | 
				
			||||||
        var _a;
 | 
					        var _a;
 | 
				
			||||||
@ -223,6 +223,7 @@ class DotnetVersionResolver {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        else {
 | 
					        else {
 | 
				
			||||||
            this.resolvedArgument.type = 'channel';
 | 
					            this.resolvedArgument.type = 'channel';
 | 
				
			||||||
 | 
					            this.resolvedArgument.qualityFlag = true;
 | 
				
			||||||
            if (ReplacingRegEx.test(this.inputVersion)) {
 | 
					            if (ReplacingRegEx.test(this.inputVersion)) {
 | 
				
			||||||
                this.resolvedArgument.value = (_a = this.inputVersion.match(ReplacingRegEx)) === null || _a === void 0 ? void 0 : _a[1];
 | 
					                this.resolvedArgument.value = (_a = this.inputVersion.match(ReplacingRegEx)) === null || _a === void 0 ? void 0 : _a[1];
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@ -231,7 +232,7 @@ class DotnetVersionResolver {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    createLineArgument() {
 | 
					    createVersionObject() {
 | 
				
			||||||
        this.resolveVersionInput();
 | 
					        this.resolveVersionInput();
 | 
				
			||||||
        if (IS_WINDOWS) {
 | 
					        if (IS_WINDOWS) {
 | 
				
			||||||
            if (this.resolvedArgument.type === 'channel') {
 | 
					            if (this.resolvedArgument.type === 'channel') {
 | 
				
			||||||
@ -265,7 +266,7 @@ class DotnetCoreInstaller {
 | 
				
			|||||||
            const installationDirectoryWindows = 'C:\\Program` Files\\dotnet';
 | 
					            const installationDirectoryWindows = 'C:\\Program` Files\\dotnet';
 | 
				
			||||||
            const installationDirectoryLinux = '/usr/share/dotnet';
 | 
					            const installationDirectoryLinux = '/usr/share/dotnet';
 | 
				
			||||||
            const versionResolver = new DotnetVersionResolver(this.version);
 | 
					            const versionResolver = new DotnetVersionResolver(this.version);
 | 
				
			||||||
            const versionObject = versionResolver.createLineArgument();
 | 
					            const versionObject = versionResolver.createVersionObject();
 | 
				
			||||||
            var envVariables = {};
 | 
					            var envVariables = {};
 | 
				
			||||||
            for (let key in process.env) {
 | 
					            for (let key in process.env) {
 | 
				
			||||||
                if (process.env[key]) {
 | 
					                if (process.env[key]) {
 | 
				
			||||||
@ -279,8 +280,8 @@ class DotnetCoreInstaller {
 | 
				
			|||||||
                    .replace(/'/g, "''");
 | 
					                    .replace(/'/g, "''");
 | 
				
			||||||
                let command = `& '${escapedScript}'`;
 | 
					                let command = `& '${escapedScript}'`;
 | 
				
			||||||
                command += ` ${versionObject.type} ${versionObject.value}`;
 | 
					                command += ` ${versionObject.type} ${versionObject.value}`;
 | 
				
			||||||
                if (this.quality) {
 | 
					                if (this.quality && versionObject.qualityFlag) {
 | 
				
			||||||
                    command += ` ${this.resolveQuality(versionObject).type} ${this.resolveQuality(versionObject).value}`;
 | 
					                    command += ` -Quality ${this.quality}`;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                if (process.env['https_proxy'] != null) {
 | 
					                if (process.env['https_proxy'] != null) {
 | 
				
			||||||
                    command += ` -ProxyAddress ${process.env['https_proxy']}`;
 | 
					                    command += ` -ProxyAddress ${process.env['https_proxy']}`;
 | 
				
			||||||
@ -319,8 +320,8 @@ class DotnetCoreInstaller {
 | 
				
			|||||||
                const scriptPath = yield io.which(escapedScript, true);
 | 
					                const scriptPath = yield io.which(escapedScript, true);
 | 
				
			||||||
                let scriptArguments = [];
 | 
					                let scriptArguments = [];
 | 
				
			||||||
                scriptArguments.push(versionObject.type, versionObject.value);
 | 
					                scriptArguments.push(versionObject.type, versionObject.value);
 | 
				
			||||||
                if (this.quality) {
 | 
					                if (this.quality && versionObject.qualityFlag) {
 | 
				
			||||||
                    scriptArguments.push(this.resolveQuality(versionObject).type, this.resolveQuality(versionObject).value);
 | 
					                    scriptArguments.push("--quality", this.quality);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                if (IS_LINUX) {
 | 
					                if (IS_LINUX) {
 | 
				
			||||||
                    scriptArguments.push('--install-dir', installationDirectoryLinux);
 | 
					                    scriptArguments.push('--install-dir', installationDirectoryLinux);
 | 
				
			||||||
@ -340,20 +341,6 @@ class DotnetCoreInstaller {
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        });
 | 
					        });
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    resolveQuality(versionObject) {
 | 
					 | 
				
			||||||
        let resolvedArgument = { type: '', value: '' };
 | 
					 | 
				
			||||||
        if (versionObject.type == '-Channel') {
 | 
					 | 
				
			||||||
            resolvedArgument = { type: '-Quality', value: `${this.quality}` };
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        else if (versionObject.type == '--channel') {
 | 
					 | 
				
			||||||
            resolvedArgument = { type: '--quality', value: `${this.quality}` };
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        else {
 | 
					 | 
				
			||||||
            core.warning("Input 'dotnet-quality' can't be used with the specified exact version of .NET. 'dotnet-quality' input will be ignored.");
 | 
					 | 
				
			||||||
            this.quality = "";
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        return resolvedArgument;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    static addToPath() {
 | 
					    static addToPath() {
 | 
				
			||||||
        if (process.env['DOTNET_INSTALL_DIR']) {
 | 
					        if (process.env['DOTNET_INSTALL_DIR']) {
 | 
				
			||||||
            core.addPath(process.env['DOTNET_INSTALL_DIR']);
 | 
					            core.addPath(process.env['DOTNET_INSTALL_DIR']);
 | 
				
			||||||
 | 
				
			|||||||
@ -33,11 +33,11 @@ export class DotnetQualityValidator {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
export class DotnetVersionResolver {
 | 
					export class DotnetVersionResolver {
 | 
				
			||||||
  private inputVersion: string;
 | 
					  private inputVersion: string;
 | 
				
			||||||
  private resolvedArgument: {type: string; value: string};
 | 
					  private resolvedArgument: {type: string; value: string, qualityFlag: boolean};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  constructor(version: string) {
 | 
					  constructor(version: string) {
 | 
				
			||||||
    this.inputVersion = version.trim();
 | 
					    this.inputVersion = version.trim();
 | 
				
			||||||
    this.resolvedArgument = {type: '', value: ''};
 | 
					    this.resolvedArgument = {type: '', value: '', qualityFlag: false};
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private resolveVersionInput(): void {
 | 
					  private resolveVersionInput(): void {
 | 
				
			||||||
@ -53,6 +53,7 @@ export class DotnetVersionResolver {
 | 
				
			|||||||
      this.resolvedArgument.value = this.inputVersion;
 | 
					      this.resolvedArgument.value = this.inputVersion;
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      this.resolvedArgument.type = 'channel';
 | 
					      this.resolvedArgument.type = 'channel';
 | 
				
			||||||
 | 
					      this.resolvedArgument.qualityFlag = true;
 | 
				
			||||||
      if (ReplacingRegEx.test(this.inputVersion)) {
 | 
					      if (ReplacingRegEx.test(this.inputVersion)) {
 | 
				
			||||||
        this.resolvedArgument.value = this.inputVersion.match(
 | 
					        this.resolvedArgument.value = this.inputVersion.match(
 | 
				
			||||||
          ReplacingRegEx
 | 
					          ReplacingRegEx
 | 
				
			||||||
@ -63,7 +64,7 @@ export class DotnetVersionResolver {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  public createLineArgument(): {type: string; value: string} {
 | 
					  public createVersionObject(): {type: string; value: string, qualityFlag: boolean} {
 | 
				
			||||||
    this.resolveVersionInput();
 | 
					    this.resolveVersionInput();
 | 
				
			||||||
    if (IS_WINDOWS) {
 | 
					    if (IS_WINDOWS) {
 | 
				
			||||||
      if (this.resolvedArgument.type === 'channel') {
 | 
					      if (this.resolvedArgument.type === 'channel') {
 | 
				
			||||||
@ -98,7 +99,7 @@ export class DotnetCoreInstaller {
 | 
				
			|||||||
    const installationDirectoryLinux = '/usr/share/dotnet';
 | 
					    const installationDirectoryLinux = '/usr/share/dotnet';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const versionResolver = new DotnetVersionResolver(this.version);
 | 
					    const versionResolver = new DotnetVersionResolver(this.version);
 | 
				
			||||||
    const versionObject = versionResolver.createLineArgument();
 | 
					    const versionObject = versionResolver.createVersionObject();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    var envVariables: {[key: string]: string} = {};
 | 
					    var envVariables: {[key: string]: string} = {};
 | 
				
			||||||
    for (let key in process.env) {
 | 
					    for (let key in process.env) {
 | 
				
			||||||
@ -115,10 +116,8 @@ export class DotnetCoreInstaller {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
      command += ` ${versionObject.type} ${versionObject.value}`;
 | 
					      command += ` ${versionObject.type} ${versionObject.value}`;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (this.quality) {
 | 
					      if (this.quality && versionObject.qualityFlag) {
 | 
				
			||||||
        command += ` ${this.resolveQuality(versionObject).type} ${
 | 
					        command += ` -Quality ${this.quality}`;
 | 
				
			||||||
          this.resolveQuality(versionObject).value
 | 
					 | 
				
			||||||
        }`;
 | 
					 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (process.env['https_proxy'] != null) {
 | 
					      if (process.env['https_proxy'] != null) {
 | 
				
			||||||
@ -169,11 +168,8 @@ export class DotnetCoreInstaller {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
      scriptArguments.push(versionObject.type, versionObject.value);
 | 
					      scriptArguments.push(versionObject.type, versionObject.value);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      if (this.quality) {
 | 
					      if (this.quality && versionObject.qualityFlag) {
 | 
				
			||||||
        scriptArguments.push(
 | 
					        scriptArguments.push("--quality", this.quality);
 | 
				
			||||||
          this.resolveQuality(versionObject).type,
 | 
					 | 
				
			||||||
          this.resolveQuality(versionObject).value
 | 
					 | 
				
			||||||
        );
 | 
					 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      
 | 
					      
 | 
				
			||||||
      if (IS_LINUX) {
 | 
					      if (IS_LINUX) {
 | 
				
			||||||
@ -196,24 +192,6 @@ export class DotnetCoreInstaller {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  private resolveQuality(versionObject: {
 | 
					 | 
				
			||||||
    type: string;
 | 
					 | 
				
			||||||
    value: string;
 | 
					 | 
				
			||||||
  }): {type: string; value: string} {
 | 
					 | 
				
			||||||
    let resolvedArgument: {type: string; value: string} = {type: '', value: ''};
 | 
					 | 
				
			||||||
    if (versionObject.type == '-Channel') {
 | 
					 | 
				
			||||||
      resolvedArgument = {type: '-Quality', value: `${this.quality}`};
 | 
					 | 
				
			||||||
    } else if (versionObject.type == '--channel') {
 | 
					 | 
				
			||||||
      resolvedArgument = {type: '--quality', value: `${this.quality}`};
 | 
					 | 
				
			||||||
    } else {
 | 
					 | 
				
			||||||
      core.warning(
 | 
					 | 
				
			||||||
        "Input 'dotnet-quality' can't be used with the specified exact version of .NET. 'dotnet-quality' input will be ignored."
 | 
					 | 
				
			||||||
      );
 | 
					 | 
				
			||||||
      this.quality = "";
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    return resolvedArgument;
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  static addToPath() {
 | 
					  static addToPath() {
 | 
				
			||||||
    if (process.env['DOTNET_INSTALL_DIR']) {
 | 
					    if (process.env['DOTNET_INSTALL_DIR']) {
 | 
				
			||||||
      core.addPath(process.env['DOTNET_INSTALL_DIR']);
 | 
					      core.addPath(process.env['DOTNET_INSTALL_DIR']);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user