mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01: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;
|