UNPKG

serverless

Version:

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

27 lines (22 loc) 607 B
'use strict'; const yaml = require('js-yaml'); const resolve = require('json-refs').resolveRefs; class YamlParser { constructor(serverless) { this.serverless = serverless; } parse(yamlFilePath) { const root = this.serverless.utils.readFileSync(yamlFilePath); const options = { filter: ['relative', 'remote'], loaderOptions: { processContent: (res, callback) => { callback(null, yaml.load(res.text)); }, }, location: yamlFilePath, }; return resolve(root, options).then((res) => res.resolved); } } module.exports = YamlParser;