UNPKG

serverless

Version:

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

17 lines (12 loc) 384 B
'use strict'; const YAML = require('js-yaml'); function parse(filePath, contents) { // Auto-parse JSON if (filePath.endsWith('.json')) { return JSON.parse(contents); } else if (filePath.endsWith('.yml') || filePath.endsWith('.yaml')) { return YAML.load(contents.toString(), { filename: filePath }); } return contents.toString().trim(); } module.exports = parse;