mirror of
https://github.com/actions/setup-dotnet.git
synced 2024-11-22 19:41:08 +07: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() {
|
constructor() {
|
||||||
this.scriptName = utils_1.IS_WINDOWS ? 'install-dotnet.ps1' : 'install-dotnet.sh';
|
this.scriptName = utils_1.IS_WINDOWS ? 'install-dotnet.ps1' : 'install-dotnet.sh';
|
||||||
this.scriptArguments = [];
|
this.scriptArguments = [];
|
||||||
this.scriptPath = '';
|
|
||||||
this.escapedScript = path_1.default
|
this.escapedScript = path_1.default
|
||||||
.join(__dirname, '..', 'externals', this.scriptName)
|
.join(__dirname, '..', 'externals', this.scriptName)
|
||||||
.replace(/'/g, "''");
|
.replace(/'/g, "''");
|
||||||
this.scriptReady = utils_1.IS_WINDOWS
|
if (utils_1.IS_WINDOWS) {
|
||||||
? this.setupScriptPowershell()
|
this.setupScriptPowershell();
|
||||||
: this.setupScriptBash();
|
return;
|
||||||
|
}
|
||||||
|
this.setupScriptBash();
|
||||||
}
|
}
|
||||||
setupScriptPowershell() {
|
setupScriptPowershell() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
@ -368,14 +369,19 @@ class DotnetInstallScript {
|
|||||||
if (process.env['no_proxy'] != null) {
|
if (process.env['no_proxy'] != null) {
|
||||||
this.scriptArguments.push(`-ProxyBypassList ${process.env['no_proxy']}`);
|
this.scriptArguments.push(`-ProxyBypassList ${process.env['no_proxy']}`);
|
||||||
}
|
}
|
||||||
this.scriptPath =
|
|
||||||
(yield io.which('pwsh', false)) || (yield io.which('powershell', true));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
setupScriptBash() {
|
setupScriptBash() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
(0, fs_1.chmodSync)(this.escapedScript, '777');
|
(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) {
|
useArguments(...args) {
|
||||||
@ -401,8 +407,7 @@ class DotnetInstallScript {
|
|||||||
ignoreReturnCode: true,
|
ignoreReturnCode: true,
|
||||||
env: process.env
|
env: process.env
|
||||||
};
|
};
|
||||||
yield this.scriptReady;
|
return exec.getExecOutput(`"${yield this.getScriptPath()}"`, this.scriptArguments, getExecOutputOptions);
|
||||||
return exec.getExecOutput(`"${this.scriptPath}"`, this.scriptArguments, getExecOutputOptions);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -129,17 +129,18 @@ export class DotnetInstallScript {
|
|||||||
private scriptName = IS_WINDOWS ? 'install-dotnet.ps1' : 'install-dotnet.sh';
|
private scriptName = IS_WINDOWS ? 'install-dotnet.ps1' : 'install-dotnet.sh';
|
||||||
private escapedScript: string;
|
private escapedScript: string;
|
||||||
private scriptArguments: string[] = [];
|
private scriptArguments: string[] = [];
|
||||||
private scriptPath = '';
|
|
||||||
private scriptReady: Promise<void>;
|
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.escapedScript = path
|
this.escapedScript = path
|
||||||
.join(__dirname, '..', 'externals', this.scriptName)
|
.join(__dirname, '..', 'externals', this.scriptName)
|
||||||
.replace(/'/g, "''");
|
.replace(/'/g, "''");
|
||||||
|
|
||||||
this.scriptReady = IS_WINDOWS
|
if (IS_WINDOWS) {
|
||||||
? this.setupScriptPowershell()
|
this.setupScriptPowershell();
|
||||||
: this.setupScriptBash();
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setupScriptBash();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async setupScriptPowershell() {
|
private async setupScriptPowershell() {
|
||||||
@ -162,14 +163,18 @@ export class DotnetInstallScript {
|
|||||||
if (process.env['no_proxy'] != null) {
|
if (process.env['no_proxy'] != null) {
|
||||||
this.scriptArguments.push(`-ProxyBypassList ${process.env['no_proxy']}`);
|
this.scriptArguments.push(`-ProxyBypassList ${process.env['no_proxy']}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.scriptPath =
|
|
||||||
(await io.which('pwsh', false)) || (await io.which('powershell', true));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async setupScriptBash() {
|
private async setupScriptBash() {
|
||||||
chmodSync(this.escapedScript, '777');
|
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[]) {
|
public useArguments(...args: string[]) {
|
||||||
@ -202,10 +207,8 @@ export class DotnetInstallScript {
|
|||||||
env: process.env as {string: string}
|
env: process.env as {string: string}
|
||||||
};
|
};
|
||||||
|
|
||||||
await this.scriptReady;
|
|
||||||
|
|
||||||
return exec.getExecOutput(
|
return exec.getExecOutput(
|
||||||
`"${this.scriptPath}"`,
|
`"${await this.getScriptPath()}"`,
|
||||||
this.scriptArguments,
|
this.scriptArguments,
|
||||||
getExecOutputOptions
|
getExecOutputOptions
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user