Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
await Promise.all(Object.keys(granulesObject).map(async (granuleId) => {
const updatedFiles = [];
updatedGranules[granuleId] = { ...granulesObject[granuleId] };
const cmrFile = cmrFiles.find((f) => f.granuleId === granuleId);
const cmrMetadata = cmrFile ? await metadataObjectFromCMRFile(cmrFile.filename) : {};
granulesObject[granuleId].files.forEach((file) => {
const cmrFileTypeObject = {};
if (cmrFileNames.includes(file.name) && !file.type) {
cmrFileTypeObject.type = 'metadata';
}
const match = fileSpecs.filter((cf) => unversionFilename(file.name).match(cf.regex));
validateMatch(match, bucketsConfig, file);
const URLPathTemplate = file.url_path || match[0].url_path || collection.url_path || '';
const urlPath = urlPathTemplate(URLPathTemplate, {
file,
granule: granulesObject[granuleId],
cmrMetadata
});
const objectPromises = cmrFiles.map(async (cmrFile) => {
const metadataObject = await metadataObjectFromCMRFile(cmrFile.filename);
const updatedFile = Object.assign({}, { ...cmrFile }, { metadataObject: metadataObject });
updatedCMRFiles.push(updatedFile);
});
await Promise.all(objectPromises);