Move cloneObject into utilities and export it.

This commit is contained in:
Remco Vermeulen 2024-07-31 17:56:06 -07:00
parent 19a1da54d1
commit 7be3a64c02
6 changed files with 12 additions and 11 deletions

5
lib/codeql.js generated
View file

@ -813,7 +813,7 @@ async function runTool(cmd, args = [], opts = {}) {
async function generateCodeScanningConfig(config, logger) {
const codeScanningConfigFile = getGeneratedCodeScanningConfigPath(config);
// make a copy so we can modify it
const augmentedConfig = cloneObject(config.originalUserInput);
const augmentedConfig = (0, util_1.cloneObject)(config.originalUserInput);
// Inject the queries from the input
if (config.augmentationProperties.queriesInput) {
if (config.augmentationProperties.queriesInputCombines) {
@ -857,9 +857,6 @@ async function generateCodeScanningConfig(config, logger) {
fs.writeFileSync(codeScanningConfigFile, yaml.dump(augmentedConfig));
return codeScanningConfigFile;
}
function cloneObject(obj) {
return JSON.parse(JSON.stringify(obj));
}
// This constant sets the size of each TRAP cache in megabytes.
const TRAP_CACHE_SIZE_MB = 1024;
async function getTrapCachingExtractorConfigArgs(config) {

File diff suppressed because one or more lines are too long

4
lib/util.js generated
View file

@ -66,6 +66,7 @@ exports.getErrorMessage = getErrorMessage;
exports.prettyPrintPack = prettyPrintPack;
exports.checkDiskUsage = checkDiskUsage;
exports.checkActionVersion = checkActionVersion;
exports.cloneObject = cloneObject;
const fs = __importStar(require("fs"));
const os = __importStar(require("os"));
const path = __importStar(require("path"));
@ -858,4 +859,7 @@ var BuildMode;
/** The database will be created by building the source root using manually specified build steps. */
BuildMode["Manual"] = "manual";
})(BuildMode || (exports.BuildMode = BuildMode = {}));
function cloneObject(obj) {
return JSON.parse(JSON.stringify(obj));
}
//# sourceMappingURL=util.js.map

File diff suppressed because one or more lines are too long

View file

@ -31,7 +31,7 @@ import * as setupCodeql from "./setup-codeql";
import { ToolsFeature, isSupportedToolsFeature } from "./tools-features";
import { shouldEnableIndirectTracing } from "./tracer-config";
import * as util from "./util";
import { BuildMode, wrapError } from "./util";
import { BuildMode, wrapError, cloneObject } from "./util";
type Options = Array<string | number | boolean>;
@ -1344,10 +1344,6 @@ async function generateCodeScanningConfig(
return codeScanningConfigFile;
}
function cloneObject<T>(obj: T): T {
return JSON.parse(JSON.stringify(obj)) as T;
}
// This constant sets the size of each TRAP cache in megabytes.
const TRAP_CACHE_SIZE_MB = 1024;

View file

@ -1100,3 +1100,7 @@ export enum BuildMode {
/** The database will be created by building the source root using manually specified build steps. */
Manual = "manual",
}
export function cloneObject<T>(obj: T): T {
return JSON.parse(JSON.stringify(obj)) as T;
}