load(data) { return yaml.load(data, {schema: this.PLATFORM_SCHEMA}); }
function construct(data) { var src, included, basepath, fullpath; basepath = yamlinc.getBasePath(); fullpath = p.join(basepath, data); yamlinc.YAML_VISITED_FILES.push(fullpath.replace(basepath + p.sep, '')); debug('resolved %s', fullpath); debug('incoming data %s', data); src = fs.readFileSync(fullpath, 'utf8'); included = yaml.load(src, { schema: yamlinc.YAML_INCLUDE_SCHEMA, filename: fullpath }); return included; }
start() { const conf = yaml.load(fs.readFileSync("./config.yaml", "utf8")); conf.services.forEach(service => { const app = require(`../${service.module}`); app(service); }); }
/** * Read in and parse a file. Current supports yaml and json * @param {string} filepath * @return {*} parsed contents of file */ static parseFile(filepath) { if (!fs.existsSync(filepath)) { throw new Error(`File [${filepath}] does not exist!`); } const contents = fs.readFileSync(fs.realpathSync(filepath)).toString('utf8'); const parsers = { '.yml': yaml.load, '.yaml': yaml.load, '.json': JSON.parse, }; const ext = path.extname(filepath); if (!(ext in parsers)) { throw new Error(`File [${filepath}] does not have a valid parser!`); } return parsers[ext](contents); }
if (src.length > 0) { yamlinc.YAML_VISITED_FILES.push(filepath); included = yaml.load(src, { schema: yamlinc.YAML_INCLUDE_SCHEMA, filename: filepath
let loadYaml = (fileName) => { return yaml.load(fs.readFileSync(fileName, 'utf8')) }