serverless/lib/plugins/aws/package/lib/save-compiled-template.js
Austen 158f644cd0
feat: Refactor logging to reduce complexity (#12432)
* chore: Change logger

* chore: continue refactor

* chore: WIP

* chore: Sync
2024-04-17 13:26:31 -07:00

23 lines
752 B
JavaScript

import fs from 'fs/promises';
import path from 'path';
export default {
async saveCompiledTemplate() {
const compiledTemplateFileName = this.provider.naming.getCompiledTemplateFileName();
const compiledTemplateFilePath = path.join(
this.serverless.serviceDir,
'.serverless',
compiledTemplateFileName
);
const shouldMinify = this.options['minify-template'];
const templateContents = this.serverless.service.provider.compiledCloudFormationTemplate;
const stringTemplateContents = JSON.stringify(templateContents, null, shouldMinify ? 0 : 2);
await fs.mkdir(path.dirname(compiledTemplateFilePath), { recursive: true });
await fs.writeFile(compiledTemplateFilePath, stringTemplateContents);
},
};