mirror of
https://github.com/serverless/serverless.git
synced 2026-01-18 14:58:43 +00:00
25 lines
986 B
JavaScript
25 lines
986 B
JavaScript
'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);
|
|
};
|