UNPKG

yaml-js-include

Version:

Extension for yaml-js library to be able to include files/directories in yaml files

28 lines 934 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getFileIncludeType = void 0; const p = require("path"); const yaml = require("js-yaml"); /** * Gets a schema for including files * @param yamlInclude YAML include object * @returns {yaml.Type} YAML type for a schema */ const getFileIncludeType = (yamlInclude) => { return new yaml.Type('tag:yaml.org,2002:inc/file', { kind: 'scalar', resolve: (data) => { return typeof data === 'string'; }, construct: (data) => { const basePath = yamlInclude.basePath; const fullPath = p.join(basePath, data); yamlInclude.basePath = fullPath; const included = yamlInclude.load(fullPath); yamlInclude.basePath = basePath; return included; }, }); }; exports.getFileIncludeType = getFileIncludeType; //# sourceMappingURL=file.js.map