(files: {
[fileName: string]: FileFsRef;
})
| 1047 | }; |
| 1048 | |
| 1049 | export async function createPseudoLayer(files: { |
| 1050 | [fileName: string]: FileFsRef; |
| 1051 | }): Promise<PseudoLayerResult> { |
| 1052 | const pseudoLayer: PseudoLayer = {}; |
| 1053 | let pseudoLayerBytes = 0; |
| 1054 | |
| 1055 | for (const fileName of Object.keys(files)) { |
| 1056 | const file = files[fileName]; |
| 1057 | |
| 1058 | if (isSymbolicLink(file.mode)) { |
| 1059 | const symlinkTarget = await fs.readlink(file.fsPath); |
| 1060 | pseudoLayer[fileName] = { |
| 1061 | file, |
| 1062 | isSymlink: true, |
| 1063 | symlinkTarget, |
| 1064 | }; |
| 1065 | } else { |
| 1066 | const origBuffer = await streamToBuffer(file.toStream()); |
| 1067 | pseudoLayerBytes += origBuffer.byteLength; |
| 1068 | pseudoLayer[fileName] = { |
| 1069 | file, |
| 1070 | isSymlink: false, |
| 1071 | crc32: crc32.unsigned(origBuffer), |
| 1072 | uncompressedSize: origBuffer.byteLength, |
| 1073 | }; |
| 1074 | } |
| 1075 | } |
| 1076 | |
| 1077 | return { pseudoLayer, pseudoLayerBytes }; |
| 1078 | } |
| 1079 | |
| 1080 | export interface CreateLambdaFromPseudoLayersOptions |
| 1081 | extends LambdaOptionsWithFiles { |
no test coverage detected