mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
22 lines
414 B
JavaScript
22 lines
414 B
JavaScript
|
'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;
|