serverless
Version:
Serverless Framework - Build web, mobile and IoT applications with serverless architectures using AWS Lambda, Azure Functions, Google CloudFunctions & more
48 lines (40 loc) • 1.77 kB
JavaScript
'use strict';
const path = require('path');
const fse = require('fs-extra');
module.exports = {
async moveArtifactsToPackage() {
const packagePath =
this.options.package ||
this.serverless.service.package.path ||
path.join(this.serverless.config.servicePath || '.', '.serverless');
// Only move the artifacts if it was requested by the user
if (this.serverless.config.servicePath && !packagePath.endsWith('.serverless')) {
const serverlessTmpDirPath = path.join(this.serverless.config.servicePath, '.serverless');
if (this.serverless.utils.dirExistsSync(serverlessTmpDirPath)) {
if (this.serverless.utils.dirExistsSync(packagePath)) {
fse.removeSync(packagePath);
}
this.serverless.utils.writeFileDir(packagePath);
this.serverless.utils.copyDirContentsSync(serverlessTmpDirPath, packagePath);
fse.removeSync(serverlessTmpDirPath);
}
}
},
async moveArtifactsToTemp() {
const packagePath =
this.options.package ||
this.serverless.service.package.path ||
path.join(this.serverless.config.servicePath || '.', '.serverless');
// Only move the artifacts if it was requested by the user
if (this.serverless.config.servicePath && !packagePath.endsWith('.serverless')) {
const serverlessTmpDirPath = path.join(this.serverless.config.servicePath, '.serverless');
if (this.serverless.utils.dirExistsSync(packagePath)) {
if (this.serverless.utils.dirExistsSync(serverlessTmpDirPath)) {
fse.removeSync(serverlessTmpDirPath);
}
this.serverless.utils.writeFileDir(serverlessTmpDirPath);
this.serverless.utils.copyDirContentsSync(packagePath, serverlessTmpDirPath);
}
}
},
};