in src/tasks/AWSShellScript/TaskOperations.ts [20:74]
public async execute(): Promise<number> {
let scriptPath = ''
try {
await this.configureAWSContext()
await SdkUtils.configureHttpProxyFromAgentProxyConfiguration('AWSShellScript')
const bash = tool(which('bash', true))
if (this.taskParameters.scriptType === inlineScriptType) {
const tempDir = SdkUtils.getTempLocation()
const fileName = `awsshellscript_${process.pid}.sh`
scriptPath = join(tempDir, fileName)
writeFileSync(scriptPath, this.taskParameters.inlineScript, { encoding: 'utf-8' })
} else {
scriptPath = this.taskParameters.filePath
}
let workingDirectory: string
if (this.taskParameters.disableAutoCwd) {
workingDirectory = this.taskParameters.workingDirectory
} else {
workingDirectory = process.env.SYSTEM_DEFAULTWORKINGDIRECTORY || dirname(scriptPath)
}
// The solution to this not working on windows comes from doing it like it's done in
// the ms task: https://github.com/microsoft/azure-pipelines-tasks/blob/master/Tasks/BashV3/bash.ts
// Thanks to the ms team opensourcing their tasks for the solution logic
if (process.platform === 'win32') {
scriptPath =
(await this.translateWindowsPath(dirname(scriptPath))) + `${posix.sep}${basename(scriptPath)}`
}
mkdirP(workingDirectory)
bash.arg(scriptPath)
if (this.taskParameters.arguments) {
bash.line(this.taskParameters.arguments)
}
const execOptions = {
cwd: workingDirectory,
env: process.env,
errStream: process.stdout,
outStream: process.stdout,
failOnStdErr: this.taskParameters.failOnStandardError
}
return await bash.exec((execOptions as unknown) as IExecOptions)
} finally {
if (this.taskParameters.scriptType === inlineScriptType && scriptPath && exist(scriptPath)) {
unlinkSync(scriptPath)
}
}
}