/** * Return the yaml parsed for a given string * * @param {string} str */ const loadString = async (str) => yaml.parse(str)
//____________________________________________________________________________ function yrequire(filename) { const s = fs.readFileSync(filename,'utf8'); return yaml.parse(s); }
const display = (filename) => { if (!fs.existsSync(scriptsPath)){ fs.mkdirSync(scriptsPath); } if(fileExists(scriptsPath+filename)){ const file = fs.readFileSync(scriptsPath+filename, 'utf8') let res = YAML.parse(file); console.log(""); read(res,"",0,false); } else { console.log(`There is no loaded script with name `+filename+` to be displayed`); } }
function __getServiceInformation(service_name) { return new Promise((resolve, reject) => { const file = fs.readFileSync('./app/gateway_conf.yml', 'utf8') const conf = yaml.parse(file) if ( conf.services.hasOwnProperty(service_name) ) { resolve(conf.services[service_name]) } else { const err = { type: 'NOT_FOUND', module_source: 'request_resolver', message: 'Invalid service access. Please check your request again/' } reject(err) } }) }
[ // Generate a random list of unique user agent strings ...Array.from( new Set( Array(1000) .fill() .map( () => new UserAgent(({ userAgent }) => !BOTS.test(userAgent)).toString() ) ) ), // Read from Yaml file ...Object.values( parse( readFileSync( join(__dirname, browserUserAgentsYaml), 'utf-8' ) ) ).flat() ].filter(Boolean)
function main(s) { let o = yaml.parse(s, { prettyErrors: true }); if (argv.verbose) console.log('Loaded definition '+defName); if (o && o.openapi) { despatch(o,config,configName,finish); } else { if (o && o.swaggerVersion && o.swaggerVersion === '1.2') { convert12(o); } else if (o && o.swagger && o.swagger === '2.0') { if (remoteConfig) { despatch(o,config,configName,finish); } else { convert20(o); } } else { console.error('Unrecognised OpenAPI/Swagger version'); } } }
const filepath = join(__dirname, filename) const content = (await readFile(filepath)).toString() const data = YAML.parse(content)
const run = (filename) => { if (!fs.existsSync(scriptsPath)){ fs.mkdirSync(scriptsPath); } let fullpath = scriptsPath+filename; if(filename.substr(0,2)=="./"||filename.indexOf('/')!=-1){ let isValid = validate(filename,false); if(isValid)fullpath=filename; else return; } if(fileExists(fullpath)){ createLog(); console.log(`You can find a complete log for this run at ./_logs/`+logName) const file = fs.readFileSync(fullpath, 'utf8') let res = YAML.parse(file); read(res,"",0); execCommands(res,0); } else { console.log(`There is no loaded script with name `+filename); } }
var results = YAML.parse(body)
function readCliConfig() { const configFile = path.join( process.env['HOME'], '.config/yandex-cloud/config.yaml' ); let config; try { config = yaml.parse(fs.readFileSync(configFile, 'utf8')); } catch (e) { throw new Error(`Failed to read config ${configFile}: ${e.toString()}`); } const current = config['current']; if (!current) { throw new Error( `Invalid config in ${configFile}: no current profile selected` ); } if (!config['profiles'][current]) { throw new Error( `Invalid config in ${configFile}: no profile named ${current} exists` ); } return config['profiles'][current]; }
[ // Read from text file ...readFileSync( join( __dirname, '../fixtures/', crawlerUserAgentsText ), 'utf-8' ).trim().split('\n'), // Read from JSON file ...require(crawlerUserAgentsJson).reduce( (accumulator, { instances }) => accumulator.concat(instances), [] ), // Read from Yaml file ...Object.values( parse( readFileSync( join(__dirname, crawlerUserAgentsYaml), 'utf-8' ) ) ).flat() ].filter(Boolean).filter(ua => !ignoreList.includes(ua))
const validate = (filename,print=true) => { let file; try{ file = fs.readFileSync(filename, 'utf8') } catch (e) { if(e.code==="ENOENT"){ console.log(`No such file by name '`+filename+`'`); } return false; } try { let res = YAML.parse(file); if(res instanceof Array){ if(print) console.log("Your YAML file is valid!"); } else { console.log("The commands in the YAML file are not in the correct format"); return false; } } catch (e){ console.log("The YAML file is not well formated"); return false; } return true; }
function yrequire(filename) { const s = fs.readFileSync(filename,'utf8'); return yaml.parse(s); }