mirror of
https://github.com/serverless/serverless.git
synced 2025-12-08 19:46:03 +00:00
17 lines
384 B
JavaScript
17 lines
384 B
JavaScript
'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;
|