mirror of
https://github.com/marcogll/passkit-generator.git
synced 2026-03-15 19:25:23 +00:00
Added management for non-existing folder-model bundle files
This commit is contained in:
@@ -130,12 +130,18 @@ async function getModelFolderContents(model: string): Promise<PartitionedBundle>
|
|||||||
|
|
||||||
// Getting all the buffers from file paths
|
// Getting all the buffers from file paths
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
...validFiles.map(file => readFile(file))
|
...validFiles.map(file =>
|
||||||
|
readFile(file).catch(() => Buffer.alloc(0))
|
||||||
|
)
|
||||||
]).then(buffers =>
|
]).then(buffers =>
|
||||||
// Assigning each file path to its buffer
|
// Assigning each file path to its buffer
|
||||||
Object.assign({}, ...validFiles.map((file, index) =>
|
validFiles.reduce<BundleUnit>((acc, file, index) => {
|
||||||
({ [file]: buffers[index] })
|
if (!buffers[index].length) {
|
||||||
)) as BundleUnit
|
return acc;
|
||||||
|
}
|
||||||
|
|
||||||
|
return { ...acc, [file]: buffers[index] };
|
||||||
|
}, {})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user