Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (configFileContent) {
try {
this._config = yaml.parseDocument(configFileContent);
const configJson = this._config.toJSON();
if(typeof configJson === 'string') {
throw new AntError(`The configuration "${configJson}" is invalid`);
}
return;
} catch (e) {
throw new AntError(
`Could not load config ${this._path}`,
e
);
}
}
this._config = new yaml.Document();
this._config.contents = new Map();
fs.writeFileSync(this._path, this._config.toString());
logger.log(`Configuration file successfully written at: ${this._path}`);
} else {
throw new AntError(`Could not load config at "${this._path}".`);
}
} else {
// Stringifies the configuration at "params" and then parses it to
// generate our YAML document tree.
this._config = yaml.parseDocument(yaml.stringify(params));
}
}