UNPKG

serverless

Version:

Serverless Framework - Build web, mobile and IoT applications with serverless architectures using AWS Lambda, Azure Functions, Google CloudFunctions & more

25 lines (20 loc) 986 B
'use strict'; const path = require('path'); const fse = require('fs-extra'); const getTmpDirPath = require('../../../utils/fs/getTmpDirPath'); const createZipFile = require('../../../utils/fs/createZipFile'); const ensureArtifact = require('../../../utils/ensureArtifact'); const srcDirPath = path.join(__dirname, 'resources'); const artifactName = 'custom-resources.zip'; module.exports = async () => { const resultPath = await ensureArtifact(artifactName, async (cachePath) => { const tmpDirPath = getTmpDirPath(); const tmpInstalledLambdaPath = path.resolve(tmpDirPath, 'resource-lambda'); const tmpZipFilePath = path.resolve(tmpDirPath, 'resource-lambda.zip'); const cachedZipFilePath = path.resolve(cachePath, artifactName); await fse.copy(srcDirPath, tmpInstalledLambdaPath); await createZipFile(tmpInstalledLambdaPath, tmpZipFilePath); await fse.move(tmpZipFilePath, cachedZipFilePath); }); return path.resolve(resultPath, artifactName); };