author ryeolj5911 gmail import fs = require ( "fs" ) ; import yaml = require ( "js-yaml" ) ; try { let yamlString = fs . readFileSync ( __dirname + '/../../../../snutt.yml' , 'utf8' ) ; var config = yaml . safeLoad ( yamlString ) ; } catch ( e ) { throw new Error ( "Could not find config file." ) ; } export function get ( key ) { let resolved = resolve ( config , key ) ; if ( resolved === undefined ) { throw new Error ( "Could not find config '" + key + "'" ) ; } return resolved ; } function resolve ( obj , path ) { let splitted = path . split ( '.' ) ; let current = obj ; while ( splitted . length > 0 ) { if ( typeof current !== 'object' ) { return undefined ; } current = current [ splitted . shift ( ) ] ; } return current ; }