mirror of
https://github.com/github/codeql-action.git
synced 2026-01-06 14:40:10 +08:00
Merge branch 'master' into analysisName
This commit is contained in:
10
src/util.ts
10
src/util.ts
@@ -3,6 +3,8 @@ import * as http from '@actions/http-client';
|
||||
import * as auth from '@actions/http-client/auth';
|
||||
import * as octokit from '@octokit/rest';
|
||||
import consoleLogLevel from 'console-log-level';
|
||||
import * as fs from "fs";
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
|
||||
import * as sharedEnv from './shared-environment';
|
||||
@@ -361,3 +363,11 @@ export function getToolNames(sarifContents: string): string[] {
|
||||
|
||||
return Object.keys(toolNames);
|
||||
}
|
||||
|
||||
// Creates a random temporary directory, runs the given body, and then deletes the directory.
|
||||
// Mostly intended for use within tests.
|
||||
export async function withTmpDir(body: (tmpDir: string) => Promise<void>) {
|
||||
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'codeql-action-'));
|
||||
await body(tmpDir);
|
||||
fs.rmdirSync(tmpDir, { recursive: true });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user