mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
414 B
22 lines
414 B
9 years ago
|
'use strict';
|
||
|
|
||
|
const yaml = require('js-yaml');
|
||
|
|
||
|
function isYAMLBlock(text) {
|
||
|
return !!text.match(/^<!-- YAML/);
|
||
|
}
|
||
|
|
||
|
exports.isYAMLBlock = isYAMLBlock;
|
||
|
|
||
|
function extractAndParseYAML(text) {
|
||
|
text = text.trim();
|
||
|
|
||
|
text = text.replace(/^<!-- YAML/, '')
|
||
|
.replace(/-->$/, '');
|
||
|
|
||
|
// js-yaml.safeLoad() throws on error
|
||
|
return yaml.safeLoad(text);
|
||
|
}
|
||
|
|
||
|
exports.extractAndParseYAML = extractAndParseYAML;
|