@rushstack/heft-config-file
Version:
Configuration file loader for @rushstack/heft
29 lines • 963 B
JavaScript
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
import { CONFIGURATION_FILE_FIELD_ANNOTATION } from './ConfigurationFileBase';
/**
* Returns an object with investigative annotations stripped, useful for snapshot testing.
*
* @beta
*/
export function stripAnnotations(obj) {
if (typeof obj !== 'object' || obj === null) {
return obj;
}
else if (Array.isArray(obj)) {
const result = [];
for (const value of obj) {
result.push(stripAnnotations(value));
}
return result;
}
else {
const clonedObj = { ...obj };
delete clonedObj[CONFIGURATION_FILE_FIELD_ANNOTATION];
for (const [name, value] of Object.entries(clonedObj)) {
clonedObj[name] = stripAnnotations(value);
}
return clonedObj;
}
}
//# sourceMappingURL=TestUtilities.js.map