mirror of
https://github.com/serverless/serverless.git
synced 2025-12-08 19:46:03 +00:00
25 lines
578 B
JavaScript
25 lines
578 B
JavaScript
import yaml from 'js-yaml'
|
|
import { resolveRefs } from 'json-refs'
|
|
|
|
class YamlParser {
|
|
constructor(serverless) {
|
|
this.serverless = serverless
|
|
}
|
|
|
|
async 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 resolveRefs(root, options).then((res) => res.resolved)
|
|
}
|
|
}
|
|
|
|
export default YamlParser
|