mirror of
https://github.com/github/codeql-action.git
synced 2026-10-31 01:49:43 +00:00
Remove dependency on del package
The latest version requires ESM, and we don't really need this dependency.
This commit is contained in:
19
lib/setup-codeql.js
generated
19
lib/setup-codeql.js
generated
@@ -39,7 +39,6 @@ const fs = __importStar(require("fs"));
|
||||
const path = __importStar(require("path"));
|
||||
const perf_hooks_1 = require("perf_hooks");
|
||||
const toolcache = __importStar(require("@actions/tool-cache"));
|
||||
const del_1 = __importDefault(require("del"));
|
||||
const fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
|
||||
const semver = __importStar(require("semver"));
|
||||
const uuid_1 = require("uuid");
|
||||
@@ -434,7 +433,7 @@ const downloadCodeQL = async function (codeqlURL, maybeBundleVersion, maybeCliVe
|
||||
const extractedBundlePath = await toolcache.extractTar(archivedBundlePath);
|
||||
const extractionMs = Math.round(perf_hooks_1.performance.now() - extractionStart);
|
||||
logger.debug(`Finished extracting CodeQL bundle to ${extractedBundlePath} (${extractionMs} ms).`);
|
||||
await cleanUpGlob(archivedBundlePath, "CodeQL bundle archive", logger);
|
||||
await cleanUpFileOrDirectory(archivedBundlePath, "CodeQL bundle archive", logger);
|
||||
const bundleVersion = maybeBundleVersion ?? tryGetBundleVersionFromUrl(codeqlURL, logger);
|
||||
if (bundleVersion === undefined) {
|
||||
logger.debug("Could not cache CodeQL tools because we could not determine the bundle version from the " +
|
||||
@@ -456,7 +455,7 @@ const downloadCodeQL = async function (codeqlURL, maybeBundleVersion, maybeCliVe
|
||||
const toolcachedBundlePath = await toolcache.cacheDir(extractedBundlePath, "CodeQL", toolcacheVersion);
|
||||
// Defensive check: we expect `cacheDir` to copy the bundle to a new location.
|
||||
if (toolcachedBundlePath !== extractedBundlePath) {
|
||||
await cleanUpGlob(extractedBundlePath, "CodeQL bundle from temporary directory", logger);
|
||||
await cleanUpFileOrDirectory(extractedBundlePath, "CodeQL bundle from temporary directory", logger);
|
||||
}
|
||||
return {
|
||||
toolsVersion: maybeCliVersion ?? toolcacheVersion,
|
||||
@@ -541,19 +540,11 @@ async function setupCodeQLBundle(toolsInput, apiDetails, tempDir, variant, defau
|
||||
}
|
||||
return { codeqlFolder, toolsDownloadDurationMs, toolsSource, toolsVersion };
|
||||
}
|
||||
async function cleanUpGlob(glob, name, logger) {
|
||||
async function cleanUpFileOrDirectory(file, name, logger) {
|
||||
logger.debug(`Cleaning up ${name}.`);
|
||||
try {
|
||||
const deletedPaths = await (0, del_1.default)(glob, { force: true });
|
||||
if (deletedPaths.length === 0) {
|
||||
logger.warning(`Failed to clean up ${name}: no files found matching ${glob}.`);
|
||||
}
|
||||
else if (deletedPaths.length === 1) {
|
||||
logger.debug(`Cleaned up ${name}.`);
|
||||
}
|
||||
else {
|
||||
logger.debug(`Cleaned up ${name} (${deletedPaths.length} files).`);
|
||||
}
|
||||
await fs.promises.rm(file, { force: true, recursive: true });
|
||||
logger.debug(`Cleaned up ${name}.`);
|
||||
}
|
||||
catch (e) {
|
||||
logger.warning(`Failed to clean up ${name}: ${e}.`);
|
||||
|
||||
Reference in New Issue
Block a user