Use commander preAction hook for setMode
Hooks are new to commander v8. We can use hooks to ensure that `setMode` is called before every command is invoked.
This commit is contained in:
parent
4b4a5ee9d1
commit
539d968ad7
18 changed files with 4114 additions and 2724 deletions
8
lib/runner.js
generated
8
lib/runner.js
generated
|
|
@ -25,7 +25,9 @@ const util_1 = require("./util");
|
|||
// eslint-disable-next-line import/no-commonjs
|
||||
const pkg = require("../package.json");
|
||||
const program = new commander_1.Command();
|
||||
program.version(pkg.version);
|
||||
program.version(pkg.version).hook("preAction", () => {
|
||||
actions_util_1.setMode(actions_util_1.Mode.runner);
|
||||
});
|
||||
function getTempDir(userInput) {
|
||||
const tempDir = path.join(userInput || process.cwd(), "codeql-runner");
|
||||
if (!fs.existsSync(tempDir)) {
|
||||
|
|
@ -98,7 +100,6 @@ program
|
|||
.option("--trace-process-name <string>", "(Advanced, windows-only) Inject a windows tracer of this process into a process with the given process name.")
|
||||
.option("--trace-process-level <number>", "(Advanced, windows-only) Inject a windows tracer of this process into a parent process <number> levels up.")
|
||||
.action(async (cmd) => {
|
||||
actions_util_1.setMode(actions_util_1.Mode.runner);
|
||||
const logger = logging_1.getRunnerLogger(cmd.debug);
|
||||
try {
|
||||
const tempDir = getTempDir(cmd.tempDir);
|
||||
|
|
@ -175,7 +176,6 @@ program
|
|||
.option("--temp-dir <dir>", 'Directory to use for temporary files. Default is "./codeql-runner".')
|
||||
.option("--debug", "Print more verbose output", false)
|
||||
.action(async (cmd) => {
|
||||
actions_util_1.setMode(actions_util_1.Mode.runner);
|
||||
const logger = logging_1.getRunnerLogger(cmd.debug);
|
||||
try {
|
||||
const config = await config_utils_1.getConfig(getTempDir(cmd.tempDir), logger);
|
||||
|
|
@ -225,7 +225,6 @@ program
|
|||
.option("--category <category>", "String used by Code Scanning for matching the analyses.")
|
||||
.option("--debug", "Print more verbose output", false)
|
||||
.action(async (cmd) => {
|
||||
actions_util_1.setMode(actions_util_1.Mode.runner);
|
||||
const logger = logging_1.getRunnerLogger(cmd.debug);
|
||||
try {
|
||||
const config = await config_utils_1.getConfig(getTempDir(cmd.tempDir), logger);
|
||||
|
|
@ -266,7 +265,6 @@ program
|
|||
.option("--category <category>", "String used by Code Scanning for matching the analyses.")
|
||||
.option("--debug", "Print more verbose output", false)
|
||||
.action(async (cmd) => {
|
||||
actions_util_1.setMode(actions_util_1.Mode.runner);
|
||||
const logger = logging_1.getRunnerLogger(cmd.debug);
|
||||
const auth = await util_1.getGitHubAuth(logger, cmd.githubAuth, cmd.githubAuthStdin);
|
||||
const apiDetails = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue