Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Config.getLocal = function getLocal(file) {
var cfg = new Config();
var json;
if(fs.existsSync(file)) {
json = xm.FileUtil.readJSONSync(file);
var schema = xm.FileUtil.readJSONSync(path.join(process.cwd(), 'schema', 'tsd-config_v4.json'));
var res = tv4.validateResult(json, schema);
if(!res.valid || res.missing.length > 0) {
console.log(res.error.message);
if(res.error.dataPath) {
console.log(res.error.dataPath);
}
if(res.error.schemaPath) {
console.log(res.error.schemaPath);
}
throw (new Error('malformed config: doesn\'t comply with schema'));
}
cfg.typingsPath = json.typingsPath;
cfg.version = json.version;
cfg.repo = json.repo;
cfg.ref = json.ref;
}
return cfg;