Skip to content

Commit

Permalink
Don't add literal double quote characters to filenames (#1984)
Browse files Browse the repository at this point in the history
* Remove unnecessary spawnSync options.

The detached option defaults to false, and the cwd option defaults to
the current working directory, so there is no need to specify them.

* Don't retrieve spawnRes properties individually.

This isn't necessary and gives the misleading impression that stdout
and stderr may contain something. They cannot since the Docker image
is run with stdio: "inherit", meaning the stdio and stderr streams are
passed through to/from the mega-linter-runner process and hence aren't
captured.

* Don't add literal " character to filenames (#1942)

The extra quotes caused MegaLinter to fail to find the first and last
files in the list on non-Windows platforms, because the first has a
literal double quote character prepended to it, and the last has one
appended to it. Stop passing Windows arguments verbatim to eliminate
the need for the quotes on Windows.

Co-authored-by: nvuillam <nicolas.vuillamy@gmail.com>
  • Loading branch information
Kurt-von-Laven and nvuillam committed Oct 22, 2022
1 parent b8777b6 commit e957998
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
Note: Can be used with `oxsecurity/megalinter@beta` in your GitHub Action mega-linter.yml file, or with `oxsecurity/megalinter:beta` docker image

- New [cupcake flavor](https://oxsecurity.github.io/megalinter/beta/flavors/cupcake/#readme) with 78 instead of 108 linters
- Don't add literal double quote character to filenames in mega-linter-runner ([#1942](https://github.com/oxsecurity/megalinter/issues/1942)).
- Remove default npm-groovy-lint extra arguments ([#1872](https://github.com/oxsecurity/megalinter/issues/1872))

- Linter versions upgrades
Expand Down
11 changes: 2 additions & 9 deletions mega-linter-runner/lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,20 +151,17 @@ ERROR: Docker engine has not been found on your system.
if ((options._ || []).length > 0) {
commandArgs.push(
...["-e"],
`MEGALINTER_FILES_TO_LINT="${options._.join(",")}"`
`MEGALINTER_FILES_TO_LINT=${options._.join(",")}`
);
}
commandArgs.push(dockerImage);

// Call docker run
console.log(`Command: docker ${commandArgs.join(" ")}`);
const spawnOptions = {
detached: false,
cwd: process.cwd(),
env: Object.assign({}, process.env),
stdio: "inherit",
windowsHide: true,
windowsVerbatimArguments: true,
};
const spawnRes = spawnSync("docker", commandArgs, spawnOptions);
// Output json if requested
Expand All @@ -179,11 +176,7 @@ ERROR: Docker engine has not been found on your system.
console.log(JSON.stringify(JSON.parse(jsonRaw)));
}
}
return {
status: spawnRes.status,
stdout: spawnRes.stdout,
stderr: spawnRes.stderr,
};
return spawnRes;
}

isv4(release) {
Expand Down

0 comments on commit e957998

Please sign in to comment.