(processOptions: ProcessOptions)
| 46 | * @param processOptions Takes a ProcessOptions type to process. |
| 47 | */ |
| 48 | export function executeProcess(processOptions: ProcessOptions): Thenable<void> { |
| 49 | outputChannel.show(); |
| 50 | outputChannel.appendLine("-".repeat(processOptions.report.length)); |
| 51 | outputChannel.appendLine(processOptions.report); |
| 52 | outputChannel.appendLine("-".repeat(processOptions.report.length)); |
| 53 | outputChannel.appendLine( |
| 54 | `${processOptions.command} ${processOptions.args.join(" ")}`, |
| 55 | ); |
| 56 | |
| 57 | return vscode.window.withProgress( |
| 58 | { |
| 59 | location: vscode.ProgressLocation.Notification, |
| 60 | title: "APKLab", |
| 61 | cancellable: true, |
| 62 | }, |
| 63 | (progress, token) => { |
| 64 | return new Promise<void>((resolve) => { |
| 65 | progress.report({ message: processOptions.report }); |
| 66 | |
| 67 | const cp = cross_spawn.spawn( |
| 68 | processOptions.command, |
| 69 | processOptions.args, |
| 70 | { |
| 71 | shell: processOptions.shell, |
| 72 | cwd: processOptions.cwd, |
| 73 | }, |
| 74 | ); |
| 75 | cp.stdout.on("data", (data) => |
| 76 | outputChannel.appendLine(data.toString().trim()), |
| 77 | ); |
| 78 | cp.stderr.on("data", (data) => |
| 79 | outputChannel.appendLine(data.toString().trim()), |
| 80 | ); |
| 81 | cp.on("error", (data) => { |
| 82 | outputChannel.appendLine(data.toString().trim()); |
| 83 | vscode.window.showErrorMessage( |
| 84 | `APKLab: ${processOptions.name} process failed.`, |
| 85 | ); |
| 86 | resolve(); |
| 87 | }); |
| 88 | cp.on("exit", async (code) => { |
| 89 | const expectedFileExists = processOptions.shouldExist |
| 90 | ? fs.existsSync(processOptions.shouldExist) |
| 91 | : true; |
| 92 | |
| 93 | if (code === 0 && expectedFileExists) { |
| 94 | outputChannel.appendLine( |
| 95 | `${processOptions.name} process was successful`, |
| 96 | ); |
| 97 | vscode.window.showInformationMessage( |
| 98 | `APKLab: ${processOptions.name} process was successful.`, |
| 99 | ); |
| 100 | if (processOptions.onSuccess) { |
| 101 | await processOptions.onSuccess(); |
| 102 | } |
| 103 | } else { |
| 104 | const errorMsg = |
| 105 | code !== 0 |
no outgoing calls
no test coverage detected