Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed a bug that caused --containername to not work #1561

Merged
merged 2 commits into from
Jun 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions mega-linter-runner/lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,12 @@ ERROR: Docker engine has not been found on your system.

// Build docker run options
const lintPath = path.resolve(options.path || ".");
const commandArgs = [
"run",
"-v",
"/var/run/docker.sock:/var/run/docker.sock:rw",
"-v",
`${lintPath}:/tmp/lint:rw`,
];
const commandArgs = [ "run" ];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: consider removing whitespace inside square brackets for consistency with other array literals.

if (options.containername) {
commandArgs.push(...["--name", options.containername]);
}
commandArgs.push(...["-v", "/var/run/docker.sock:/var/run/docker.sock:rw"]);
commandArgs.push(...["-v", `${lintPath}:/tmp/lint:rw`]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: I like the clarity of keeping each argument on its own line; this clarity can be retained with marginally less code in a single push:

commandArgs.push([
  "-v", "/var/run/docker.sock:/var/run/docker.sock:rw",
  "-v", `${lintPath}:/tmp/lint:rw`
]);

if (options.fix === true) {
commandArgs.push(...["-e", "APPLY_FIXES=all"]);
}
Expand All @@ -134,9 +133,6 @@ ERROR: Docker engine has not been found on your system.
commandArgs.push(...["-e", envVarEqualsValue]);
}
}
if (commandArgs.containername) {
commandArgs.push(...["--name", commandArgs.containername]);
Kurt-von-Laven marked this conversation as resolved.
Show resolved Hide resolved
}
commandArgs.push(dockerImage);

// Call docker run
Expand Down