MCPcopy Create free account
hub / github.com/Azure/powershell / executeFile

Method executeFile

src/ScriptRunner.ts:19–51  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17 }
18
19 async executeFile() {
20 const error: string[] = [];
21 const options: any = {
22 listeners: {
23 stderr: (data: Buffer) => {
24 if (error.length < 10) {
25 // Truncate to at most 1000 bytes
26 if (data.length > 1000) {
27 error.push(`${data.toString('utf8', 0, 1000)}<truncated>`);
28 } else {
29 error.push(data.toString('utf8'));
30 }
31 } else if (error.length === 10) {
32 error.push('Additional writes to stderr truncated');
33 }
34 }
35 }
36 };
37 const scriptToExecute: string = new ScriptBuilder().getInlineScriptFile(
38 this.inlineScript, this.errorActionPreference);
39 ScriptRunner.filePath = await FileUtils.createScriptFile(scriptToExecute);
40 core.debug(`script file to run: ${ScriptRunner.filePath}`);
41 const exitCode: number = await PowerShellToolRunner.executePowerShellScriptBlock(ScriptRunner.filePath, options);
42 if (exitCode !== 0) {
43 core.setOutput(`Azure PowerShell exited with code:`, exitCode.toString());
44 if (this.failOnStandardErr) {
45 error.forEach((err: string) => {
46 core.error(err);
47 });
48 throw new Error(`Standard error stream contains one or more lines`);
49 }
50 }
51 }
52}

Callers 1

mainFunction · 0.95

Calls 4

toStringMethod · 0.80
getInlineScriptFileMethod · 0.45
createScriptFileMethod · 0.45

Tested by

no test coverage detected