Skip to content

Commit

Permalink
Use shell mode for executing commands to avoid issues in with some me…
Browse files Browse the repository at this point in the history
…son builds

In Windows when running the plugin with the MSYS2 Meson package, the plugin throws the error "Meson version doesn't match expected output:". After some investigation I found that the response from execFile was returning: error: null, stdout: "" and stderr: "1.3.0". I was unable to replicate this behavior in a shell, so I updated execFile to use "shell" mode by default, which solves the issue.

This seems to be specific to the MSYS2 package of meson, since using the pip version runs fine. However, since this is such a simple change that should not affect functionality, I thought I'd submit it.
  • Loading branch information
aidenfoxx authored Nov 27, 2023
1 parent a6d44ce commit 3946f91
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface ExecResult {
error?: cp.ExecFileException;
}

export async function exec(command: string, args: string[], options: cp.ExecOptions = {}) {
export async function exec(command: string, args: string[], options: cp.ExecFileOptions = { shell: true }) {
return new Promise<ExecResult>((resolve, reject) => {
cp.execFile(command, args, options, (error, stdout, stderr) => {
if (error) {
Expand All @@ -25,7 +25,12 @@ export async function exec(command: string, args: string[], options: cp.ExecOpti
});
}

export async function execFeed(command: string, args: string[], options: cp.ExecOptions = {}, stdin: string) {
export async function execFeed(
command: string,
args: string[],
options: cp.ExecFileOptions = { shell: true },
stdin: string,
) {
return new Promise<ExecResult>((resolve) => {
const p = cp.execFile(command, args, options, (error, stdout, stderr) => {
resolve({ stdout, stderr, error: error ? error : undefined });
Expand Down

0 comments on commit 3946f91

Please sign in to comment.